【发布时间】:2018-11-09 10:25:44
【问题描述】:
我想在导航栏上创建动态路由并将其重定向到http://localhost:8000/tasks/nenad 页面
Web.php
Route::get('/tasks/{first_name}', 'Viewercontroller@profile')
->middleware('viewer')
->name('profile');
查看器控制器
public function profile($first_name) {
$user = User::whereFirst_name($first_name)->first();
return view('viewers/tasks', compact('user'));
}
Navbar.blade.php:
<li><a href="{{ url(route('profile')) }}">Tasks</a></li>
我知道我必须更改导航栏页面上的链接,但不知道如何,任何帮助都会很棒...
【问题讨论】:
-
需要传递参数
route('profile', ['first_name' => 'some_name])。 laravel.com/docs/5.6/routing#named-routes
标签: php laravel hyperlink routes