I have a create for the registration of users where there is a MULTIPLE SELECT to assign several entities to the user.
And he throws an array for each option I frame.
So I have the multiple select:
<label for="entity_id">Asignar Entes</label>
<select id="ms" name="entity_id[]" multiple="multiple">
@foreach($entities as $e)
<option value="{{$e->id}}">{{$e->name}}</option>
@endforeach
</select>
And the driver to save the user's data:
public function store(Request $request)
{
$user= new \App\User();
$user->name=$request->name;
$user->email=$request->email;
$user->entity_id=$request->entity_id;
$user->role_id=$request->role_id;
$user->password=bcrypt($request->password);
if($user->save()){
return redirect()->route('users.index', $user->id)
->with('info', 'Usuario guardado con éxito');
}
else{
return redirect()->route('users.index')
->with('info', 'No se guardó el usuario');
}
}
And the fields of the database, where entity_id is the field that I want to save:
How do I store that array in my database? thanks in advance.