-
resources/views/navigation-dropdown.blade.php
Open in GitHub// You can check the current route NAME from Blade with request()->routeIs() passing the route NAME (not URL) // See the examples, there's route name "dashboard", and also "tasks.*" with a star - means any symbols after that // Also see routes/web.php below for the corresponding task names // If you want to check the current route by URL instead of route names // you do the same but without "route": // request()->is('tasks/*') - that would check any URL that starts with "/tasks/" <!-- Navigation Links --> <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex"> <x-jet-nav-link href="{{ route('dashboard') }}" :active="request()->routeIs('dashboard')"> {{ __('Dashboard') }} </x-jet-nav-link> </div> @can('task_access') <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex"> <x-jet-nav-link href="{{ route('tasks.index') }}" :active="request()->routeIs('tasks.*')"> Tasks </x-jet-nav-link> </div> @endcan
-
routes/web.php
Open in GitHub// In this example, we have a route named "dashboard" // And also automatically assigned route names to Resource controllers, like "tasks.index", "tasks.create" etc. Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () { return view('dashboard'); })->name('dashboard'); Route::group(['middleware' => 'auth'], function () { Route::resource('tasks', \App\Http\Controllers\TasksController::class); Route::resource('users', \App\Http\Controllers\UsersController::class); });