skip to Main Content

I am having this route setup on my laravel app which uses the FooController which uses an __invoke method

Route::get('/foos/{foo:baz_param}', FooController::class)->name('foos');

I am also having a link in my blade template which is this

<a href="{{ route('foos', ['baz_param' => $foo->baz_param]) }}">
     {{ $foo->baz_param }}
</a>

however I am getting the following error on screen

Missing required parameter for [Route: foos] [URI: foos/{foo}] [Missing parameter: foo].

How can I fix this?

2

Answers


  1. Based what error says, it expects parameter name as foo. So yon can modify your key name to match parameter name.

    <a href="{{ route('foos', ['foo' => $foo->baz_param]) }}">
    

    Or modify your Route parameter name to match the key in link.

    Route::get('/foos/{baz_param}', ...);
    
    Login or Signup to reply.
  2. This should work aswell as long as $foo contains a variable baz_param:

    <a href="{{ route('foos', $foo) }}">
       {{ $foo->baz_param }}
    </a>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search