1. Go to this page and download the library: Download nbdev/bersiv-api-response library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nbdev / bersiv-api-response example snippets
use NBDev\BersivApiResponse\Facades\BersivApiResponse;
return BersivApiResponse::detail('user', $user_resource);
use Illuminate\Http\JsonResponse;
use NBDev\BersivApiResponse\Facades\BersivApiResponse;
class AuthController
{
public function login(): JsonResponse
{
return BersivApiResponse::login([
'user' => [
'id' => 1,
'email' => '[email protected]',
],
'token' => [
'token' => 'sample-token',
'device_name' => 'web',
],
]);
}
}
return BersivApiResponse::invalidInputs(
errors: [
'email' => ['The email field is