public function lastUpdated() { $query = BarcodeProcess::orderBy('updated_at', 'DESC')->first(); if ($query) { return $query->updated_at->format('Y-m-d H:i:s'); } return date("Y-m-d H:i:s"); }
/** * Display a listing of the BarcodeProcess. * * @param Request $request * * @return Response */ public function statistic(Request $request) { $input = $request->all(); $query = BarcodeProcess::select(\DB::raw('count(*) as total_transactions, shelf_id, created_at'))->groupBy('shelf_id'); /** * Filter */ $this->barcodeProcessRepository->filter($input, $query); /** * Get count */ $total = $query->count(); /** * Pagination */ $this->barcodeProcessRepository->pagination($input, $query); $barcodeProcesses = $query->get(); $meta = array('total' => $total, 'count' => count($barcodeProcesses), 'offset' => isset($input['offset']) ? (int) $input['offset'] : 0, 'last_updated' => $this->barcodeProcessRepository->lastUpdated(), 'status' => "BarcodeProcesses retrieved successfully.", 'error' => 'Success'); return Response::json(ResponseManager::makeResult($barcodeProcesses->toArray(), $meta)); }