laravel 的 api 认证中间件,基于jwt。
composer require cola/hector
用户模型中 use Cola\Hector\HasApiToken
Route::middleware('auth:hector')->xxxxx;
$account->createToken();
向token中添加自定义字段
$account->withPayloads(['role' => $account->roles()->first()->name])->createToken();
$account->payloads['role'];