你好,我叫这个网址 http:/127.0.0.1:8000作者Tohidda。 我看到404 not found错误,我使用这个路线,但不能工作!......我的路线和controllelr是
Route::get('/author/{username}','UserController@author')->name('dashboard.author');
public function author(User $user , Course $course,$username)
{
$courses = Learning::with('course')->take(1)->latest()->get();
$categories = Category::where('parent','0')->get();
return view('Home.dashboard.author',compact('categories','user','courses','course','favorites'));
}
注:在用户表中,我的用户名是Tohidda。
这个路由可能是正确访问的. Laravel因为找不到用户模型而发出404信号. 你用用户名访问用户, 而默认情况下你应该用 id
的用户。
您可以使用 name
但你需要指示laravel这样做。你需要定义 name
作为key.See: https:/laravel.comdocs7.xeloquent#eloquent-model-conventions。