detinu20
detinu20

Reputation: 319

Missing required parameters for route, multiple parameter statement

I have encountered a problem, it seems i'm missing 'slug'from the link, if i put in that $slug i get an undefined variable, any ideas on how i should define the slug in that button? Missing required parameters for [Route: thread.show] [URI: forum/{slug}/t={id}].

Controller:

 public function show($slug)
    {
        //
        $forum = Forum::where('slug', '=', $slug)->first();
        $thread = Thread::all()->sortBy('created_at');
    return view('forum.show')->with('forum', $forum)->withThread($thread);
}

view:

           @foreach($forum->threads as $threads)
            <a href="{{route('thread.show', $threads->id)}}"><p>{{$threads->threadname}}</p></a>
           @endforeach

Upvotes: 0

Views: 1683

Answers (1)

sam
sam

Reputation: 5599

When a route requires multiple parameters you pass in an array of values, e.g:

route('thread.show, ['slug' => $thread->slug, 'id' => $thread->id]);

Upvotes: 3

Related Questions