laravel / folio

Page based routing for Laravel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Route Model Bidding + Route Multi-Segments

devajmeireles opened this issue · comments

commented

Folio Version

1.0.0

Laravel Version

Latest

PHP Version

8.1.21

Description

What

I don't know if an update to README.md (docs) is enough or if the Laravel team wants to do something about it, but the multi-parameter route system eliminates Route Model Bidding:

Something like this:

CleanShot 2023-07-26 at 3 03 24

When accessing profiles/1 in the browser, [...ids].blade.php have priority over [User].blade.php, even [User].blade.php was created after. Perhaps the Laravel team knows about this and is aware, but here's my suggestion 👇

Suggestion

Adapting make:folio:

The make:folio command can intercept this situation and give a visual feedback to the dev.

Throw An Exception

The access of a route that contains a trying to use Route Model Bidding together of Route Multi-Segments can simple try and exception providing a feedback to the dev.


Hope this help,

Thanks.

Steps To Reproduce

  1. Prepare your application, including seeding the database with fake users
  2. Install Folio and prepare them to be used
  3. Run make:folio "profiles/[...ids]"
  4. Run make:folio "profiles/[User]"
  5. Try to access the profiles/1 and check that [...ids] will works instead of [User]

Perhaps the [User] should have a higher priority and it should be possible to collocate both but definitely, User should have priority over multiple parameters.

Multi-segment routes take precedence.