I'm trying to make a multiple insert with Laravel 5.3
in a table as follows:
Form
{!! Form::open(['route' => 'demanda.store', 'class' => 'form']) !!}
<div class="form-group form-inline">
{!! Form::label('ano', 'Ano:'); !!}
{!! Form::text('ano', $ano, ['class'=>'form-control','readonly']); !!}
</div>
<div class="form-group form-inline">
@foreach ($unidades as $unidade)
<div class="form-group">
{!! Form::hidden('item_id[]', $items->id, null); !!}
{!! Form::hidden('ano[]', $ano); !!}
{!! Form::label('unidade', $unidade->sigla); !!}
{!! Form::hidden('unidade_id[]', $unidade->id, null); !!}
{!! Form::text('qtd[]', null,['class'=>'form-control','placeholder' =>'Demanda'])!!}
</div>
@endforeach
</div>
{!! Form::submit('Salvar', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
How would I get my controller to insert this data into my table, knowing that the fields in my table are:
ano
tem_id
unidade_id
qtd
Controller
public function store(DemandaFormRequest $request)
{
$dataForm = $request->all();
$insert = $this->demanda->insert($dataForm);
}
I get the following error :
QueryException in Connection.php line 770: Array to string conversion