Skip to content

Commit

Permalink
BUGFIX 🐛 Towards a more resilient template (#20)
Browse files Browse the repository at this point in the history
* Update Header.php
* Update AdminLayout.php
  • Loading branch information
ndeblauw authored Feb 20, 2025
1 parent 2f964e2 commit 987f3ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/View/Components/Adminlayout/AdminLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ndeblauw\BlueAdmin\View\Components\Adminlayout;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Illuminate\View\Component;

class AdminLayout extends Component
Expand Down Expand Up @@ -43,7 +44,7 @@ private function findActiveTopLevelMenuItem()
$routename = Route::currentRouteName();

$fake_index_routename = str($routename)->replace(['show', 'create', 'edit'], 'index')->toString();
$current_route = Route::has($fake_index_routename)
$current_route = Str::of($fake_index_routename)->contains('.index') && Route::has($fake_index_routename)
? str(route($fake_index_routename))->replace(config('app.url').'/','')->toString()
: Route::current()->uri; // todo - make more fault tolerant !!! (https etc)

Expand Down
3 changes: 2 additions & 1 deletion src/View/Layouts/FluxAdmin/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ndeblauw\BlueAdmin\View\Layouts\FluxAdmin;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Illuminate\View\Component;

class Header extends Component
Expand Down Expand Up @@ -34,7 +35,7 @@ public function findActiveTopLevelMenuItem()
{
$routename = Route::currentRouteName();
$fake_index_routename = str($routename)->replace(['show', 'create', 'edit'], 'index')->toString();
$current_route = Route::has($fake_index_routename)
$current_route = Str::of($fake_index_routename)->contains('.index') && Route::has($fake_index_routename)
? str(route($fake_index_routename))->replace(config('app.url').'/','')->toString()
: Route::current()?->uri;

Expand Down

0 comments on commit 987f3ed

Please sign in to comment.