/** * Update database statistics * * @param int $redirectId */ private function updateStatistics($redirectId) { $now = Carbon::now(); /** @var Redirect $redirect */ $redirect = Redirect::find($redirectId); if ($redirect === null) { return; } $redirect->update(['hits' => DB::raw('hits + 1'), 'last_used_at' => $now]); $crawlerDetect = new CrawlerDetect(); Client::create(['redirect_id' => $redirectId, 'timestamp' => $now, 'day' => $now->day, 'month' => $now->month, 'year' => $now->year, 'crawler' => $crawlerDetect->isCrawler() ? $crawlerDetect->getMatches() : null]); }