Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
response | |
0.00% |
0 / 28 |
|
0.00% |
0 / 3 |
110 | |
0.00% |
0 / 1 |
success | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
failed | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getError | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
56 |
1 | <?php |
2 | |
3 | namespace App\Traits; |
4 | |
5 | trait response |
6 | { |
7 | public static function success($message, $statusCode = 200, $dataName = '', $data = ''){ |
8 | if($dataName == ''){ |
9 | return response()->json([ |
10 | 'successful' => true, |
11 | 'message' => $message, |
12 | ], $statusCode); |
13 | } else { |
14 | return response()->json([ |
15 | 'successful' => true, |
16 | 'message' => $message, |
17 | $dataName => $data, |
18 | ], $statusCode); |
19 | } |
20 | } |
21 | |
22 | public static function failed($message, $statusCode = 400, $status = 'E00'){ |
23 | return response()->json([ |
24 | 'successful' => false, |
25 | 'status' => $status, |
26 | 'message' => $message, |
27 | ], $statusCode); |
28 | } |
29 | |
30 | public function getError($input){ |
31 | if ($input == "E01") |
32 | return 'authentication'; |
33 | |
34 | else if ($input == "E02") |
35 | return 'blocked'; |
36 | |
37 | else if ($input == "E03") |
38 | return 'validation'; |
39 | |
40 | else if ($input == "E04") |
41 | return 'not found'; |
42 | |
43 | else if ($input == "E05") |
44 | return 'not verified'; |
45 | |
46 | else if ($input == "E06") |
47 | return 'expired'; |
48 | else |
49 | return ""; |
50 | } |
51 | } |