Laravel 护照创建令牌在 plesk 服务器上不起作用

Laravel passport create token doesnt work on plesk server

我在 laravel 项目中使用通行证通过 api 对用户进行身份验证。 API 在我的本地主机上正常工作。但是在我将它部署到 Plesk 服务器上之后,令牌没有创建。始终显示服务器错误。

public function login(Request $request) {
    $validator = Validator::make($request->all(),[
        'email'    => 'required',
        'password' => 'required',
    ]);

    if($validator->fails()) {
        return response()->json(["validation errors" => $validator->errors()]);
    }

    $email  =   $request->email;
    $password = $request->password;
    error_log($password);
    $user   =   DB::table("users")->where([["email", "=", $email]])->first();

    if(is_null($user)) {
        return response()->json(["success" => false, "message" => "User doesn't exist"]);
    }

    if(Auth::attempt(['email' => request('email'), 'password' => request('password')])) {
        $user = Auth::user();
        $token = $user->createToken('token')->accessToken;
        $success['success'] = true;
        $success['user'] = $user;
        $success['message'] = "Success! you are logged in successfully";
        $success['token'] = $token;
        return response()->json(['success' => $success ], 200);
    } else {
        return response()->json(['error' => 'Unauthorised'], 401);
    }
}

$token = $user->createToken('token')->accessToken; 这行抛出错误

问题出在我的 AuthServiceProvider

class AuthServiceProvider extends ServiceProvider
{

    protected $policies = [
        'Medicare\Model' => 'Medicare\Policies\ModelPolicy',
    ];

    public function boot()
    {
        $this->registerPolicies();
        Passport::routes();
        //
    }
}

在我评论后 'Medicare\Model' => 'Medicare\Policies\ModelPolicy' 一切正常。