1

i have this function in controller:

public function deleteItem( $id){

this in routes:

Route::delete('deleteItem', 'CommandsController@deleteItem')->name('deleteItem');

and i try to call it from view like this:

{!! Form::open(['method' => 'DELETE', 'route' => ['deleteItem', $item->id]]) !!}

but when i confirm form i get in browser address:

deleteItem?5

questions are how to get parameter in controller or how to pass parameter to get this address:

deleteItem/5

thank you

2 Answers 2

1

Route parameters in Laravel are being denoted via curly braces like

Route::delete('deleteItem/{id}', 'CommandsController@deleteItem')->name('deleteItem');

however according to the docs

echo Form::open(['action' => ['CommandsController@deleteItem', $item->id]])

is the correct way of sending parameters to the Controller in charge, which will send the $id parameter straight as the argument of the function.

Sign up to request clarification or add additional context in comments.

Comments

0

you don't pass the id parameter at all to the controller.

try changing

Route::delete('deleteItem'

to

Route::delete('deleteItem/:id'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.