@@ 15-32 (lines=18) @@ | ||
12 | /** |
|
13 | * @param ResponseFactory $factory |
|
14 | */ |
|
15 | public function run($factory) |
|
16 | { |
|
17 | $factory->macro('errorMessage', |
|
18 | /** |
|
19 | * Return an error JSON message from the application. |
|
20 | * Called like: response()->successMessage(...) |
|
21 | * |
|
22 | * @param string $message |
|
23 | * @param int $status |
|
24 | * @param array $headers |
|
25 | * @return JsonResponse |
|
26 | */ |
|
27 | function ($message = '', $status = HttpResponse::HTTP_INTERNAL_SERVER_ERROR, array $headers = []) use ( |
|
28 | $factory |
|
29 | ) { |
|
30 | return $factory->error([], $message, $status, $headers); |
|
31 | }); |
|
32 | } |
|
33 | } |
|
34 |
@@ 14-29 (lines=16) @@ | ||
11 | /** |
|
12 | * @param ResponseFactory $factory |
|
13 | */ |
|
14 | public function run($factory) |
|
15 | { |
|
16 | $factory->macro('successMessage', |
|
17 | /** |
|
18 | * Return a success JSON message response from the application. |
|
19 | * Called like: response()->successMessage(...) |
|
20 | * |
|
21 | * @param string $message |
|
22 | * @param int $status |
|
23 | * @param array $headers |
|
24 | * @return \Illuminate\Http\JsonResponse |
|
25 | */ |
|
26 | function ($message = '', $status = HttpResponse::HTTP_OK, array $headers = []) use ($factory) { |
|
27 | return $factory->success([], $message, $status, $headers); |
|
28 | }); |
|
29 | } |
|
30 | } |
|
31 |