Skip to content

[9.x] Add method to remove a middleware from a group - #44780

Merged
taylorotwell merged 5 commits into
laravel:9.xfrom
mateusjatenee:remove-middleware
Oct 31, 2022
Merged

taylorotwell merged 5 commits into
laravel:9.xfrom
mateusjatenee:remove-middleware

Conversation

@mateusjatenee

Copy link
Copy Markdown
Contributor

On Magic Test, I need to dynamically register a middleware and in some situations that middleware needs to also be removed.

The current way is rebinding the middleware in the container to an implementation that doesn't really do anything. I think having the ability to remove it from a group is a cleaner way to do it, and since you can already rebind dependencies on the container I don't think it'd be a problem.

P.S: this PR also includes some tests for pushMiddlewareToGroup, in case it isn't accepted I can send it on a separate PR.
Also: I wasn't sure if I should use types or not on this PR since it is aimed at v9, but I can add them if necessary. 👍

@taylorotwell
taylorotwell merged commit 779fe61 into laravel:9.x Oct 31, 2022
@mateusjatenee
mateusjatenee deleted the remove-middleware branch October 31, 2022 14:13
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.

2 participants