Install using composer:
composer require soloslee/json-response
Add the service provider in config/app.php
:
'Soloslee\JsonResponse\JsonResponseServiceProvider::class',
And add the JsonResponse alias to config/app.php
:
'JsonResponse' => Soloslee\JsonResponse\Facades\JsonResponse::class,
Start by creating an JsonResponse
instance (or use the JsonResponse
Facade if you are using Laravel):
use Soloslee\JsonResponse\JsonResponse;
return JsonResponse::success();
JsonResponse::success([
'id' => $user->id,
'phone' => $user->phone,
'email' => $user->email,
'authorized' => $user->cleaner,
'token' => $user->token
]);
JsonResponse::error('Fails to send message.', 602);
Laravel Json Response is licensed under MIT license.