Medium
How to manage access control (Authorization) to a request (One possible answer)?
Author: Louis PrevosteauStatus: PublishedQuestion passed 21 times
Edit
1
Community Evaluations
Romain Herault
06/10/2023
Question peut-ĂȘtre un peu ambiguĂ«, on peut aussi ĂȘtre amenĂ© Ă cocher "avec des exceptions (try/catch)" en plus de la bonne rĂ©ponse. Dans un controller mettre un try/catch autour d'un Gate::allows() est possible.
Par exemple :
```php
try {
if (!Gate::allows('update-article', $article)) {
throw new AuthorizationException();
}
// ...
} catch (AuthorizationException $e) {
// ...
}
```
Sûrement spécifier qu'il n'y a qu'une seule bonne réponse ?
Similar QuestionsMore questions about Laravel
11
What is the purpose of the Laravel Sanctum tool?3
How to manage an email verification system in a Laravel project?3
List all routes of a Laravel project2
Which folder(s) below are present by default at the root of a new Laravel project?2
What are the functions included in Laravel to facilitate processing on strings, arrays, URLs, or other elements called?