mirror of
https://gitlab.com/izyim/prototypes/lumen-microservices/microservice-api-gateway.git
synced 2026-08-19 04:24:15 +00:00
26 lines
611 B
PHP
26 lines
611 B
PHP
<?php
|
|
|
|
|
|
namespace App\Traits;
|
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
trait ApiResponse
|
|
{
|
|
|
|
public function successResponse($data, $statusCode = Response::HTTP_OK)
|
|
{
|
|
return response($data, $statusCode)->header('Content-Type', 'application/json');
|
|
}
|
|
|
|
public function errorResponse($errorMessage, $statusCode)
|
|
{
|
|
return response()->json(['error' => $errorMessage, 'error_code' => $statusCode], $statusCode);
|
|
}
|
|
|
|
public function errorMessage($errorMessage, $statusCode)
|
|
{
|
|
return response($errorMessage, $statusCode)->header('Content-Type', 'application/json');
|
|
}
|
|
} |