-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fea9c6
commit 262f151
Showing
4 changed files
with
210 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Traits; | ||
|
||
use Illuminate\Http\Response; | ||
|
||
trait ApiResponse | ||
{ | ||
public function retrieveReponse($message = null, mixed $data = null, $code = Response::HTTP_OK) | ||
{ | ||
return $this->responseHandle(status: true, message: $message, data: $data, code: $code); | ||
} | ||
|
||
private function responseHandle(bool $status, string $message = null, mixed $data = null, int $code) | ||
{ | ||
$response = [ | ||
'status' => $status, | ||
'message' => $message, | ||
'data' => $data?->response()->getData(true), | ||
]; | ||
return response($response, $code); | ||
} | ||
} |
Oops, something went wrong.