Files
microservice-api-gateway/app/Traits/ApiResponse.php
T
Behzad Babaei 91f96ceecd initial commit
2020-03-28 17:07:00 +04:30

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');
}
}