Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor #52071

Closed
wants to merge 2 commits into from
Closed

refactor #52071

wants to merge 2 commits into from

Conversation

justinkekeocha
Copy link

@justinkekeocha justinkekeocha commented Jul 9, 2024

update to #52067

Since Laravel 11.x, the AuthorizesRequests trait was removed from base controller class. Also the base controller class no longer extends the Illuminate\Routing\Controllers\Middleware;

These two above are important for authorizeResource method to work properly in controllers. 

There are a lot of question to why authorizeResource is removed even in the documentation. 

see: 

laravel#50673
laravel#50552
https://laracasts.com/discuss/channels/laravel/help-on-authorizeresource-alternative-in-laravel-11
laravel#50566

The same solution is proposed in all the above.

The problem with that solution is that middleware cannot be defined in controllers this way : https://laravel.com/docs/11.x/controllers#controller-middleware . As recommended in the documentation, because the middleware implementation the controller class will clash with the one in Illuminate\Routing\Controllers\Middleware. I am guessing this is why that method was removed in documentation and use of gate is promoted. 

This commit also makes use of gates and removes the need to extend Illuminate\Routing\Controllers\Middleware.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant