Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ericknyoto's avatar

Missing required parameter for Route

I have no clue why this error comes up. I've re-check my code, and it was as documentation instructed.

This my route: Route::get('/insurer/{insurer}', [InsurerController::class, 'show'])->middleware(['auth'])->name('insurer.show');

And this how I called it return redirect()->route('insurer.show', $this->insurerId); I also tried: return redirect()->route('insurer.show', ['insurer' => $this->insurerId]); And not working.

What I'm missing here?

0 likes
16 replies
martinbean's avatar

@ericknyoto Is the route wrapped in a group that requires another parameter? It’s hard to diagnose since you’ve not shown us the full error. Which required parameter is missing?

So, two possibilities:

  1. The value you’re trying to use for the insurer parameter is null.
  2. There’s another required parameter that you’re not passing a value for.
ericknyoto's avatar

@martinbean I'm sure that the parameter is not null, because I dump the parameter first before redirect it. Here is the error

Missing required parameter for [Route: insurer.show] [URI: insurer/{insurer}] [Missing parameter: insurer].

And here is the controller

    {
        return view('insurer.show', [
            'insurer' => $insurer,
        ]);
    }```

SilenceBringer's avatar

@ericknyoto so, as @martinbean said, your insurere id is null. Check it right before calling

dd($this->insurerId);
return redirect()->route('insurer.show', $this->insurerId);
webrobert's avatar

just a guess.. you didnt share the Controller code here...

Route::get('/insurer/{id}', [InsurerController::class, 'show'])->middleware(['auth'])->name('insurer.show');
ericknyoto's avatar

Here is the controller

    {
        return view('insurer.show', [
            'insurer' => $insurer,
        ]);
    }```
siangboon's avatar

why it is $this->insurerId instead of model?? did you assign the value properly or you simply mess up with model??

ericknyoto's avatar

Thanks, your questions makes me passed the model instead of Id, and it worked! I don't know why, It should worked even if we pass the Id right?

Snapey's avatar

are you also calling the route from within the view insurer.show ?

ericknyoto's avatar

Finaly, I managed to make it work, by passing the model instead of Id. I don't know why it will throw parameter missing of I passed only Id. I thought Laravel will auto injection.

Snapey's avatar

Are you sure that insurerId is the primary key ?

1 like
kea_rajab's avatar

maybe am also missing the whole picture... from my understanding $this is an instance of your current class... Or the variable you are trying to call, hasnt been defined yet...

public function anyFunc($yourvariable){
	return Yourfunction($yourvariable);
}

or

public $variable;

public function anyFunc(){
	return Yourfunction($this->variable);
}

unless you are calling this from the insurer class/ model to be specific

EliyasYari's avatar

This method works for you :

web.php :

Route::get('groups/remove/{id}',Controller@remove)->name('remove_groups');

file blade :

{{ route('remove_groups',$list['id']) }}

Result :

url/groups/remove/20

Please or to participate in this conversation.