I have started programming after two years and switched from zendframework2 to laravel. i am following a youtube tutorial which is made in the earlier version of laravel. i have defined a simple route in web.php
which gives me a working url of admin/dashboard
i have been using it in this project until i used it in my slider.blade.php
the route admin/dashboard works with Request::is but does not work with href route. i get an error of admin/dashboard is not defined. but it is defined in web.php and also in php artisan route:list as admin/dashboard. i have also tried to define admin/dashboard outside Route::group in web.php and using admin.dashboard but i can't get out of this. it might be
Html:
<li class="{{ Request::is('admin/dashboard*')? 'active':''}} ">
<a class="nav-link" href="{{route('admin/dashboard')}}"> <i class="material-icons">dashboard</i> <p>Dashboard</p> </a>
</li>
Route:
Route::group(['middleware' => 'auth'], function () {
Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'Admin\DashboardController@index'])->name('admin.dashboard');
});
web.php:
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
//beneath is the route that can work both for auth and non auth for admin/
Route::group(['prefix' => 'admin', 'as' => 'admin.'], function () {
Route::group(['middleware' => 'auth'], function () {
Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'Admin\DashboardController@index'])->name('admin.dashboard');
Route::resource('slider', 'Admin\SliderController');
});
});