Shani
Shani

Reputation: 99

How to get URI to route in Laravel5

When a user click 'Delete' button, following URI is generated

http://localhost:8888/item?id=32

in my route.php I used

Route::get('item/id={ID}','ItemsController@destroy');

But it doesn't get the input and delete the record. I have created my destroy method properly and when I give URI manually as

http://localhost:8888/item/id=32

it deletes the record.

Why Laravel doesn't capture item?id=32? How to fix this?

Thanks in advance.

Upvotes: 0

Views: 418

Answers (1)

Pranab Mitra
Pranab Mitra

Reputation: 389

You have to change the route to make this("http://localhost:8888/item?id=32") working, you can try the following:

Route::get('item','ItemsController@destroy');

and receive the id in the controller, by doing following things:

$id = Input::get('id');
// then do whatever you want for this id.. here Destroy

Second way

If you want to make "http://localhost:8888/item/id=32" working, then you have to change the delete link. Make the link like the below one:

'http://localhost:8888/item/id=' + {IdWillBePlacedHere}

Upvotes: 2

Related Questions