DEV Community

Discussion on: How to create your own middleware for User Role in Laravel without using a package?

Collapse
 
farouk2u profile image
FAROUK BLALOU

Thanks for the solution.

And you can use the spread operator to make it more simple and clean :

public function handle($request, Closure $next, ...$authorizedRoles) {

}
Enter fullscreen mode Exit fullscreen mode

and test on the $authorizedRoles array .