I have a problem in the controller with the UPDATE, my STORE is as follows:
public function store(Request $request)
{
$date = Carbon::now('America/Asuncion')->toDateTimeString();
$cabcaja = new cab_caja($request->all());
$cabcaja->fecha_inicio = $date;
$cabcaja->estado = 1;
$cabcaja->save();
Flash::success("Caja abierta en fecha");
return redirect()->route('caja_actual.index');
}
There he keeps everything perfect. But when updating the bd using the UPDATE:
public function update(Request $request, $id)
{
$datefin = Carbon::now('America/Asuncion')->toDateTimeString();
$cabb_caja = cab_caja::find($id);
$cabb_caja->fecha_fin = $datefin;
$cabb_caja->estado = 0;
$cabb_caja->fill($request->all());
$cabb_caja->save();
Flash::warning('La caja ha sido cerrada.');
return redirect()->route('index');
}
I update the field "start_date" to the current date (the same as end_date). I'm using Laravel in its version 5.1
dd ($ request-> all ()):
array:6 [▼ "_method" => "PUT" "_token" => "TgjPpopkNFjD8vxbwc1gVZo6wTSa1nI36ZqmsNsR" "gs_cierre" => "9443" "pe_cierre" => "3967" "gs_arreglo" => "100" "pe_arreglo" => "399" ] –
Array attributes before save ():
#attributes: array:12 [▼
"id" => 15
"fecha_inicio" => "2016-07-29 00:37:43"
"fecha_fin" => "2016-07-29 00:43:13"
"gs_apertura" => 5999.0
"pe_apertura" => 3334.0
"gs_cierre" => "9443"
"pe_cierre" => "3967"
"estado" => 0
"gs_arreglo" => "0"
"pe_arreglo" => "0"
"created_at" => "2016-07-29 04:37:43"
"updated_at" => "2016-07-29 04:37:43"
]