public function destroy($id) { $cacheTag = ['checkouts']; $_model = Checkouts::find($id); if ($_model) { Logs::create(['activity' => 'destroy', 'module' => 'checkouts', 'ref' => $id]); Cache::tags($cacheTag)->flush(); if ($_model->company_id === config('global.companies.current.id')) { return $_model->delete(); } else { return new \Exception("Você não tem permissão para realizar esta ação"); } } else { return new \Exception("Houve um erro ao localizar registro (id not found)"); } }
public function checkouts() { $count = Checkouts::select(\DB::raw('count(id) as total'))->where('created_at', '>', Carbon::now()->subDays(30))->where('company_id', config('global.companies.current.id'))->count(); return $this->jsonResponse(['data' => $count]); }