Files
unified-restaurant-original/backend/app/Exceptions/NotAuthorizedException.php

23 lines
492 B
PHP

<?php
namespace App\Exceptions;
use Exception;
class NotAuthorizedException extends Exception {
protected $user;
public function __construct($user) {
$this->user = $user;
}
public function render($request) {
$path = $request->getPathInfo();
return response()->json([
'error' => 'not_authorized',
'message' => 'El usuario ' . $this->user->id . ' no tiene permiso para acceder al endpoint ' . $path
], 401);
}
}