public function viewJobId($user_id, $job_id) { $today = date('Y-m-d'); $from = date('Y-m-d H:i:s', strtotime($today . ' 00:00:00')); $to = date('Y-m-d H:i:s', strtotime($today . ' 23:59:59')); $viewed = CompanyJobView::where('user_id', '=', $user_id)->where('job_id', '=', $job_id)->whereBetween('created_at', [$from, $to])->count(); if (!$viewed) { $view = new CompanyJobView(); $view->user_id = $user_id; $view->job_id = $job_id; $view->save(); } }
public function getDailyJobPostViews($job_id) { $date_lists = $this->getDateLists($job_id); $dates = CompanyJobView::select(DB::raw('DATE(created_at) as created_date'), DB::raw('COUNT(*) as count'))->where('job_id', '=', $job_id)->groupBy('created_date')->get()->toArray(); return $this->processDates($date_lists, $dates); }