dousao8152
2017-02-22 04:18
浏览 262
已采纳

laravel 5路由传递两个参数

i have this route

Route::get('/artist/{id}/{name}', 'HomeController@artist')->where(['id' => '[0-9]+', 'name' => '[a-z]+'])->name('artist');

and this is my link

<a href="{{route('artist',$artist->id,$artist->name)}}">{{$artist->name}}</a>

and this is the artist method on HomeController

public function artist($id, $name){ $artist = Artist::where('id', $id)->where('name', $name)->first();

    return view('front.artist', compact('artist'));
}

i donot know this display error. this is the error. so please any one help me with this. iam in the middle of learning laravel.

ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: artist] [URI: artist/{id}/{name}]. (View: C:\xampp\htdocs\laravelesources\views\front\home.blade.php)

1条回答 默认 最新

相关推荐 更多相似问题