php - Missing required parameters for [Route: employees.update] laravel

Solution:

Your route parameter is employee not employees. Route parameter names for resource routes are singular by default. The route is actually like this:

employees/{employee}

So in your edit method of your Controller you are using the wrong parameter name so you are getting a new instance of Employee instead of the Implicit Route Model Binding that would inject the instance based on the route parameter, you need to match the typehinted parameter name to the route parameter name:

//                            {employee}
public function edit(Employee $employee)
{
    ...
    return view(...., ['employee' => $employee]);
}

Now in the view you will have your actual existing Employee instance that you can use to generate the URL to the route instead of an empty Employee that does not have an id which was returning null:

{{ route('employees.update', ['employee' => $employee->id]) }}
// or
{{ route('employees.update', ['employee' => $employee]) }}

The route system can get the correct key from the model instance.

Answer

Solution:

You should pass $employees->id as a hidden input field.

Make your route as

 Route::post('employee/update', 'YourController@yourFunction');

and in the edit page the form action should look like

<form action="{{ route('employees.update'}}" method="POST">

make a hidden input field for passing id

<input type="hidden" name="id" value="{{$employees->id}}"></input>

Answer

Solution:

You should pass the route name to the route function like this

route('route name',parameter1)

Example :

Route::post('employee/update/{id}' ,YourController@update)->name('update_employee');

    <form action="{{ route('update_employee',$employees->id) }}" method="POST">
        @csrf
...

Source