4

So in my Laravel project I have routes foor requests, which look classically like

Route::get('edit/{user}', 'AdminUserController@getUser');
Route::post('delete', 'AdminUserController@deleteUser');

etc. The problem is that I don't know how to pass variables via get request links. For example, when I pass some variable with my link, like

$.get("{{action('Admin\AdminUserController@editUser')}}", {user: id})

I get link that looks like

/edit?user=123

And this format does not match with one written in roures.php, where just slash is mentioned. What should I do to make this work properly? Somehow make get request look like /edit/123 or rewrite something in routes?

P.S I know that I could simply use $.get('/edit/'+id), but I strongly need it to be {{action}}!

Coffee
  • 2,063
  • 8
  • 24
  • 57

1 Answers1

3

As your route you should send id with url not saperately as data. it will be something like

url : "/edit/id",

or make your route as Route::get('edit', 'AdminUserController@getUser'); and edit the row of id equals to $request->id;

Vishal B
  • 653
  • 2
  • 12
  • 31