You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
508 B
18 lines
508 B
<?php
|
|
|
|
namespace App\Exceptions\Renderers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Permission\Exceptions\UnauthorizedException;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class PermissionExceptionRenderer
|
|
{
|
|
public function __invoke(UnauthorizedException $e, Request $request): Response
|
|
{
|
|
return response()->json([
|
|
'message' => 'Bạn không có quyền truy cập.',
|
|
'required' => $e->getRequiredRoles() ?? $e->getRequiredPermissions(),
|
|
], 403);
|
|
}
|
|
}
|
|
|