laravel / folio

Page based routing for Laravel.
MIT License
568 stars 46 forks source link

Route::currentRouteName() for Laravel Folio named route returns 'laravel-folio' #89

Closed richeklein closed 1 year ago

richeklein commented 1 year ago

Folio Version

v1.0.0-beta.6

Laravel Version

10.19.0

PHP Version

8.2.3

Description

When using a named route in Laravel Folio the Route::currentRouteName() function returns "laravel-folio" instead of the route name defined in the name function. I'm not sure if this is required for Folio's magic or just unintended.

Steps To Reproduce

  1. create a new Folio page
  2. add a name — e.g. name('about')
  3. the output of Route::currentRouteName() equals "laravel-folio" instead of "about"
hazwan91 commented 1 year ago

I also have the same problem when checking if my current nav-item is active using request()->routeIs('dashboard.index') and it always return false since the current route name keeps giving me laravel-folio as the OP said.

Screenshot 2023-08-21 132325

Currently i have to use request()->is('dashboard') to determine my current page which indicates my folder/file name.

jdion84 commented 1 year ago

Routes seem to always use the fallback name, guessing it's something to do with the service provider lifecycle or something.

Route::fallback($this->handler())->name('laravel-folio');