Question from the Laravel test

How to protect a route in Laravel

Medium

How to manage access control (Authorization) to a request (One possible answer)?

Author: Louis PrevosteauStatus: PublishedQuestion passed 12 times
Edit
1
Community Evaluations
developer avatar
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 ?