I have the following code to dynamically generate check-boxes from one table:
{!! Form::open(['url' =>URL::to('admin/user/'.$profileUser->id) , 'method'=>'PUT', 'enctype'=>'multipart/form-data' ]) !!}
@foreach ($userRoles as $key => $userRole)
<tr>
<td width="10%"></td>
<td></td>
</tr>
@endforeach
<tr></tr>
</tbody>
In the controller I have:
if (isset($_POST['roleSubmit'])){
DB::table('role_users')->where('user_id', $request->get('id', $id))->delete();
$userRole = json_encode($request->input('rolename'));
DB::table('role_users')->insert(
array(
'user_id' => $id,
'role_id' => $userRole
)
);
return redirect()->back();
}
I need to dynamically generate multiple checkboxes from 'roles' table
Then I need to store the checkbox values in 'role_users' like this:
Instead, for the above snippet of code, I am getting this:
Any guideline where I am messing it?
Aucun commentaire:
Enregistrer un commentaire