hey guys i need i need help with create a register and update in other table in the same method
i mean, have this code in my view create.blade.php
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="copropietario_id">seleccione departamento que paga</label>
{!! Form::select('copropietario_id', $copropietario, null, ['class'=>'form-control','placeholder'=>'Seleccione un departamento','required','id'=>'copropietario_id']) !!}
</div>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="totalmes">Deuda total del departamento</label>
<input type="number" name="totalmes" id="totalmes" readonly value="" class="form-control">
</div>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="fecha">Ingresar Fecha de Ingreso</label>
<input type="date" name="fecha" value=" " class="form-control" placeholder="Ingrese la fecha del ingreso">
</div>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="monto">Ingresar Monto del Pago</label>
<input type="number" name="monto" id="monto" required value="" onkeyup="calculate(this.value);" class="form-control" placeholder="Ingrese el monto del pago...">
</div>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="deuda">Saldo pendiente</label>
<input type="number" readonly name="deuda" id="deuda" value="" class="form-control" placeholder="Total de la deuda...">
</div>
</div>
and need save all this request in a table ingresos, all good for me until here, the problem now is that i need update 2 values in other table, table morosos, here i need update:
monto deuda
same value that create in ingresos, but need update in table morosos.
now how can make the code here?
public function store(ComprobanteIngresoFormRequest $request, $copropietario_id)
{
$Ingresos= new ComprobanteIngreso;
$Ingresos->cliente_id=$request->get('cliente_id');
$Ingresos->copropietario_id=$request->get('copropietario_id');
$Ingresos->fecha=$request->get('fecha');
$Ingresos->formapago=$request->get('formapago');
$Ingresos->monto=$request->get('monto');
$Ingresos->fondos=$request->get('fondos');
$Ingresos->nulo=$request->get('nulo');
$Ingresos->descripcion=$request->get('descripcion');
$Ingresos->cheque=$request->get('cheque');
$Ingresos->banco=$request->get('banco');
$Ingresos->deuda=$request->get('deuda');
//$Ingresos->save();
$Morosos= Morosos::findOrFail($copropietario_id);
$Morosos->montopago = $request->get('monto');
$Morosos->totalmoroso = $request->get('deuda');
dd($Ingresos, $Morosos);
$Morosos->update();
return Redirect::to('admin/ingresos');
}
the update will be make it in morosos where copropietario_id is the same that i select in "select option" or the same copropietario_id when i create a new ingresos...
hope you understand my problem guys...
thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire