Method of a resource route does not receive argument in laravel 5.7

1

I am deleting and editing in a simple crud with laravel 5.7 but when using a resource path with its respective edit and delete methods (edit and destroy respectively), the method in question does not receive the id argument that I am passing: codes are these:

View:

<form action="{{route('events.destroy',$event->id)}}" method="POST">
            @csrf
            @method('DELETE')
            <button type="submit" class="btn btn-danger">Eliminar</button>
</form>

Route:

Route::resource('events', 'EventController');

Controller:

    public function destroy($id)
{ 
    dd($id);
}

The variable $ event receives the id, I'm going through each record with a foreach ... and probe and if it is sending the variable but the method does not receive the error is this:

    
asked by Susje 28.11.2018 в 19:18
source

1 answer

0

Brother and check, the way I pass the parameters as you need them would be like this:

{{ route('evaluations.analyst.check', ['evaluation_id' => $data->id]) }}

In your case, it should be something like this:

{{ route('events.destroy',['event_id' => $event->id]) }}

This should solve your error.

    
answered by 29.11.2018 в 01:52