快速构建laravel api服务
$ composer require jasonc/api
$ php artisan api:install
$ php artisan vendor:publish
return $this->message(string $message);
return $this->success(array $data);
return $this->failed(string $error);
<?php
namespace App\Exceptions;
use Jason\Api\Traits\ApiException;
class Handler extends ExceptionHandler
{
use ApiException;
}
修改User模型
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jason\Api\Traits\ApiGuardable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use ApiGuardable;
}