public function newWeek(Request $request) { $arr = []; $obj = Mansked::where('branchid', $request->user()->branchid)->orderBy('createdate', 'DESC')->get()->first(); if (count($obj) <= 0) { $arr['weekno'] = date('W', strtotime('now')); $arr['year'] = date('Y', strtotime('now')); $arr['weekdays'] = $this->getDaysByWeekNo($arr['weekno']); } else { if (lastWeekOfYear() > $obj->weekno) { $arr['weekno'] = $obj->weekno + 1; $arr['year'] = $obj->year; $arr['weekdays'] = $this->getDaysByWeekNo($obj->weekno + 1); $arr['lmanskedid'] = $obj->id; } else { $arr['weekno'] = 1; $arr['year'] = Carbon::now()->addYear()->year; $arr['weekdays'] = $this->getDaysByWeekNo(1, $arr['year']); $arr['lmanskedid'] = $obj->id; } } return $arr; }
/******* end prefix:api ********/ }); /******* end middeware:auth ********/ get('branch', function () { return App\User::with(['bossbranch' => function ($query) { $query->select('bossid', 'branchid', 'id')->with(['branch' => function ($query) { $query->select('code', 'descriptor', 'id'); }]); }])->get(); }); get('getweek', function () { return range(14, 17); $arr = []; for ($i = 2008; $i < 2021; $i++) { $date = Carbon\Carbon::parse($i . '-08-27'); array_push($arr, ['year' => $i, 'day' => $date->endOfYear()->format('Y-m-d D'), 'week' => $date->endOfYear()->weekOfYear, 'wday' => $date->endOfYear()->dayOfWeek, 'lwoy' => lastWeekOfYear($i)]); } return $arr; }); get('dailysales/recompute', function () { $dss = App\Models\DailySales::all(); //$dss = App\Models\DailySales::take(10)->get(); foreach ($dss as $ds) { $headspend = $ds->custcount == '0' ? 0 : $ds->sales / $ds->custcount; $tipspct = $ds->sales == '0.00' || $ds->sales == '0' ? 0 : $ds->tips / $ds->sales * 100; $mancostpct = $ds->sales == '0.00' || $ds->sales == '0' ? 0 : 650 * $ds->empcount / $ds->sales * 100; $cospct = 0; if (is_null($ds->cos)) { $ds->headspend = number_format($headspend, 2); $ds->tipspct = number_format($tipspct, 2); $ds->mancostpct = number_format($mancostpct, 2);