0

I have an EDIT button

<td><a href="{{action('InventoryItemController@edit', [$inventoryitem['id'], $inventoryitem['inventory_id']])}}" class="btn btn-warning">Edit</a></td>

And when i press it, it should edit an item based on ID and then when i update it, it should update it based on ID which works, but when I want to redirect back to index page I have to pass argument for that index method. So i added that inventory_id parameter to be passed along ID parameter but it wont recognize my inventory_id parameter in mine form.

<form method="put" action="{{action('InventoryItemController@update', $id, $inventory_id)}}">

But i get this error

Undefined variable: inventory_id 

my route is like this

Route::post('inventory-items/{id}/{inventory_id}', 'InventoryItemController@update');
Zolak94
  • 126
  • 1
  • 2
  • 11
  • Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – Douwe de Haan Jun 04 '18 at 09:10

2 Answers2

0

Error is here:

<form method="put" action="{{action('InventoryItemController@update', $id, $inventory_id)}}">

The route should look like:

route('InventoryItemController@update', ['id' => $id, 'inventory_id' => $inventory_id ])

Good luck!

Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51
0

I found easier way to do it, I just used one of the parameters ($id) in controller to find second parameter. Thanks for answers.

Zolak94
  • 126
  • 1
  • 2
  • 11