I'm trying to make multiple inserts using the same ID with Laravel but it's only doing 1 insert.
The idea would look something like this.
ped_cod|est_cod|ped_qtde
8 |2 |9
8 |3 |2
8 |4 |2
8 |9 |15
MODEL
class EstoqueDet extends Model
{
protected $table = 'public.estoque_det';
protected $primaryKey = 'ped_cod';
}
CONTROLLER (Check if input is bringing something if Yes does insert)
$caneta = $this->request->get('caneta_input');
$sulfite = $this->request->get('sulfite_input');
$tonner = $this->request->get('tonner_input');
$pasta = $this->request->get('pasta_input');
$estoqdet = $this->estoqueDet;
if(isset($caneta)) {
$estoqdet->ped_cod = $pedido_id;
$estoqdet->est_cod = $cod_caneta;
$estoqdet->ped_qtde = $caneta;
$estoqdet->save([$estoqdet]);
}
if(isset($sulfite)) {
$estoqdet->ped_cod = $pedido_id;
$estoqdet->est_cod = $cod_sulfite;
$estoqdet->ped_qtde = $sulfite;
$estoqdet->save([$estoqdet]);
}
if(isset($tonner)) {
$estoqdet->ped_cod = $pedido_id;
$estoqdet->est_cod = $cod_tonner;
$estoqdet->ped_qtde = $tonner;
$estoqdet->save([$estoqdet]);
}
if(isset($pasta)) {
$estoqdet->ped_cod = $pedido_id;
$estoqdet->est_cod = $cod_pasta;
$estoqdet->ped_qtde = $pasta;
$estoqdet->save([$estoqdet]);
}