0
How to update the database in case id=54 updating radio inputs meet with value=a / purchase with value=c.
Obs:
This is a purchase request made by the user, I would like to give an update only in the attendpurchase field according to radio input above.
@foreach($detalhes as $detalhe)
<tr>
<td>
<div class="col-xs-6">
Atender <input type="radio" name="atendecompra[{{ print $i}}]" value="a" checked="true">
</div>
<div class="col-xs-6">
Comprar<input type="radio" name="atendecompra[{{ print $i}}]" value="c">
</div>
</td>
</tr>
<?php $i++;?>
@endforeach
Controllher
public function update(Request $request, $id){
$idproduto=$request->get('idproduto');
$atendecompra=$request->get('atendecompra');
$cont = 0;
while($cont < count($idproduto)){
$detalhe = new RequisicaoDet();
$detalhe->idrequisicao=$id;
$detalhe->atendecompra=String($atendecompra)[$cont];
$detalhe->update();
$cont=$cont+1;
}
return Redirect::to('almoxarifado/requisicao');
}
Model
class RequisicaoDet extends Model
{
protected $table ='requisicaodet';
protected $primaryKey ='idrequisicaodet';
public $timestamps =false;
protected$fillable =[
'idrequisicao',
'idproduto',
'qnt',
'detalhe',
'idcentrocusto',
'atendecompra'
];
protected $guarded =[];
}
Welcome to Stackoverflow, the problem described in your question was not very clear, could edit to try to explain better
– Lucas Duete
In your case is a flag, a number that identifies each
radio
, and with this you can compare and change the value when you want, missed even pass more information Model, Controller for us to have a bigger idea of the problem!– novic
thanks for the feedback I will edit and pass the model and controller
– frodrigues