public function getNextCode() { $latest = Parcels::max('code'); $latestfromBatch = Batch::max('code'); $thisDay = Carbon::now()->format('ymd'); if (!$latest || $thisDay != substr($latest, 0, 6)) { return Carbon::now()->format('ymdH') . '001'; } if ($latestfromBatch && $latestfromBatch > $latest) { return ++$latestfromBatch; } return ++$latest; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { // dd($request); $saldo = Saldo::find($id); $data = $saldo->getFillable(); $willupdate = $request->only($data); if ($willupdate['batch_id'] == null) { $willupdate['batch_id'] = Batch::max('id') + 1; } Saldo::find($id)->update($willupdate); return redirect('saldo'); }