Изменить сообщение с неверной областью действия - PullRequest
0 голосов
/ 15 июня 2019

Как я могу изменить недопустимые сообщения, указанные в паспорте Laravel enter image description here

Ответы [ 2 ]

0 голосов
/ 15 июня 2019

попробуйте обновить render function в app/Exceptions/Handler.php файле

public function render($request, Exception $exception)
    {
        if ($exception instanceof \Laravel\Passport\Exceptions\MissingScopeException) 
        {
          return response()->json(['message' => 'your message here']); 
          //abort(401); 
        }

        return parent::render($request, $e);
    }
0 голосов
/ 15 июня 2019

Вы можете поймать это как Exception как в вашем контроллере :

try {

// Whatever you are doing which leads to such error.


} catch (MissingScopeException $e) {
    return response()->json(['message' => 'YOUR DESIRED MESSAGE.']);
}

Кстати, это то, где приводит к такому исключению.

...