Tuesday, February 28, 2017

Laravel - Append row id to form name attribute inside each row of a dynamic table

I send two variable to my view $abilities, and $users. $abilities is an array of key-value pairs containing data in the following format:

["1"=>"create_user","2"=>"delete_user","3"=>"ban_user"]

$users is an array in the following format:

["1"=>"John Doe","2"=>"Jane Doe"]

Both are taken from their respective databases abilities (columns: ID, name) and users (columns: ID, name).

In the view, I have a table which contains a multiple select for each row against the $user->id:

@foreach($users as $user)
<tr>
    <td></td>
    <td>
       
   </td>
</tr>
@endforeach

Problem is that when I receive the request in my controller, I only see one takenabilities[] array, and I want to save data from each multiple select in each row generated dynamically, if that makes sense?




via omrakhur

Advertisement