3

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\laravel\resources\views\front\home.blade.php) 

1 Answer 1

3

Yo must pass the parameters as array, see https://laravel.com/docs/5.4/helpers#method-route

route('artist',['id' => $artist->id, 'name' => $artist->name])

or you can use

{!! link_to_route('artist', $artist->name, ['id' => $artist->id, 'name' => $artist->name]) !!}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.