两年后开始编程,从 zendframework2 切换到 laravel。我正在关注在早期版本的 Laravel 中制作的 youtube 教程。我在 web.php 中定义了一个简单的路由
这给了我一个管理/仪表板的工作网址
我一直在这个项目中使用它,直到我在我的 slider.blade.php 中使用它
路由管理/仪表板适用于 Request::is 但不适用于 href 路由。我收到未定义管理/仪表板的错误。但它在 web.php 和 php artisan route:list 中定义为 admin/dashboard。我还尝试在 web.php 中的 Route::group 之外定义 admin/dashboard 并使用 admin.dashboard 但我无法摆脱这个。有可能
网址:
<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::group(['middleware' => 'auth'], function () {
Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'Admin\DashboardController@index'])->name('admin.dashboard');
});
网页.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');
});
});
慕的地8271018
白衣染霜花
慕工程0101907