我有两个模型client和user。对于Web登录,我已经将用户模型用作超级管理员。但我希望通过api请求将客户端模型用于移动登录。
api.php
Route::group(['middleware' => 'auth:api'],function() {
Route::resource('communities','communityAPIController');
Route::resource('communities','communityAPIController');
Route::resource('clients','ClientAPIController');
});
Config / auth.php
'guards' => [
'web' => [
'driver' => 'session','provider' => 'users',],'api' => [
'driver' => 'token','provider' => 'clients','hash' => false,'providers' => [
'users' => [
'driver' => 'eloquent','model' => App\User::class,'clients' => [
'driver' => 'eloquent','model' => \App\Models\Client::class,
我的客户模型是这样的。
<?php
namespace App\Models;
use Eloquent as Model;
class Client extends Model
{
public $table = 'clients';
public $fillable = [
'name','phone','house_no','type','is_approved','community_id'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer','name' => 'string','phone' => 'string','house_no' => 'string','type' => 'integer','is_approved' => 'boolean','community_id' => 'integer'
];
}
我想对auth:api使用客户端模型而不是用户模型。请帮我