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

Fix routes order to work with fallback() method #310

Merged
merged 5 commits into from
Jul 31, 2020
Merged

Fix routes order to work with fallback() method #310

merged 5 commits into from
Jul 31, 2020

Conversation

d13r
Copy link
Contributor

@d13r d13r commented Jul 25, 2020

This puts the route list into the correct order when the fallback() method is used.

The code is taken directly from Laravel core:
https://github.com/laravel/framework/blob/29c64cb6c1d8cc712463c63fcf60c0a46fe3455e/src/Illuminate/Routing/AbstractRouteCollection.php#L77-L81

More detailed explanation:

If the routes are defined as:

Route::fallback('NotFoundController')->name('errors.404');
Route::get('something', 'SomethingController')->name('something');

And you are on /something then Laravel returns the something page, but Ziggy's route().current() method currently returns errors.404, and route().current('something') returns false.

(In this trivial example you could, of course, reorder the routes - but they are actually split across several packages.)

@bakerkretzmar bakerkretzmar self-requested a review July 27, 2020 13:02
@bakerkretzmar bakerkretzmar added enhancement in progress We're working on it labels Jul 27, 2020
@bakerkretzmar bakerkretzmar changed the base branch from master to develop July 31, 2020 20:39
Copy link
Collaborator

@bakerkretzmar bakerkretzmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks!

@bakerkretzmar bakerkretzmar merged commit 90dcb58 into tighten:develop Jul 31, 2020
@d13r
Copy link
Contributor Author

d13r commented Aug 1, 2020

No problem - thank you! 😃

@bakerkretzmar bakerkretzmar removed the in progress We're working on it label Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants