I'm creating a form and I need to send the selected checkboxes to the bank. I have the table conta
, conta_categoria
and categoria
. In conta_categoria
I have id_conta
and id_categoria
.
How would I send all selected checkbox data to conta_categoria
?
My form create.blade
<div class="form-group">
{!! Form::label('descricao', 'Categoria: ') !!}
@foreach (Realito\Categoria::all() as $categoria)
<br>
{!! Form::checkbox('descricao[]',$categoria->id_categoria) !!}
{{ $categoria->id }}
{{ $categoria->descricao }}
</br>
@endforeach
</div>
My account controller where you are inserting the data
if ($ account-> save ()) {
$contasCategoria = new \App\ContasCategoria();
$contasCategoria->id_conta = $ultimoID;
$contasCategoria->id_categoria = $request->get('categoria[]');
// $contasCategoria->id_categoria = $codCategoria;
$conta->contasCategoria()->save($contasCategoria);
}