Forbidden
extends Exception
in package
Exception thrown when an authenticated user lacks permission to access a resource.
This exception should be thrown when a user is authenticated but does not have the necessary permissions to access a resource. It corresponds to HTTP 403 Forbidden status code.
Tags
Table of Contents
Properties
- $permission : string|null
- $resource : string|null
Methods
- __construct() : mixed
- getPermission() : string|null
- Get the permission that was lacking
- getResource() : string|null
- Get the resource that was forbidden
Properties
$permission
private
string|null
$permission
$resource
private
string|null
$resource
Methods
__construct()
public
__construct([string $message = 'Access forbidden' ][, string|null $resource = null ][, string|null $permission = null ][, int $code = 403 ][, Throwable|null $previous = null ]) : mixed
Parameters
- $message : string = 'Access forbidden'
-
The error message
- $resource : string|null = null
-
The resource that was forbidden (e.g., 'User Profile', 'Document #123')
- $permission : string|null = null
-
The permission that was lacking (e.g., 'admin.edit', 'document.read')
- $code : int = 403
-
The exception code (defaults to 403)
- $previous : Throwable|null = null
-
Previous exception for chaining
getPermission()
Get the permission that was lacking
public
getPermission() : string|null
Return values
string|nullgetResource()
Get the resource that was forbidden
public
getResource() : string|null