diff --git a/app/Http/Responses/ApiErrorResponse.php b/app/Http/Responses/ApiErrorResponse.php new file mode 100644 index 00000000..4ad3845f --- /dev/null +++ b/app/Http/Responses/ApiErrorResponse.php @@ -0,0 +1,50 @@ + $this->message]; + + if (!is_null($this->exception) && config('app.debug')) { + $response['debug'] = [ + 'message' => $this->exception->getMessage(), + 'file' => $this->exception->getFile(), + 'line' => $this->exception->getLine(), + 'trace' => $this->exception->getTraceAsString(), + ]; + } + + return response()->json([ + $response, + 'status' => $this->status, + 'timestamp' => now()->toDateTimeString(), + ], $this->status, $this->headers); + } + +} diff --git a/app/Http/Responses/ApiSuccessResponse.php b/app/Http/Responses/ApiSuccessResponse.php new file mode 100644 index 00000000..b8deb1ed --- /dev/null +++ b/app/Http/Responses/ApiSuccessResponse.php @@ -0,0 +1,41 @@ +json( + [ + 'status' => $this->status, + 'data' => $this->data, + 'timestamp' => now()->toDateTimeString(), + ], + $this->status, + $this->headers + ); + } + +}