/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, \Closure $next) { $locale = $this->request->segment(1) ?: App::getLocale(); $item = $this->menuItem->findByUriInLanguage($this->request->segment(2), $locale); if ($this->isOffline($item)) { App::abort(404); } return $next($request); }
/** * @param string $uri * @param string $locale * @return object */ public function findByUriInLanguage($uri, $locale) { return $this->cache->tags($this->entityName, 'global')->remember("{$this->locale}.{$this->entityName}.findByUriInLanguage.{$uri}.{$locale}", $this->cacheTime, function () use($uri, $locale) { return $this->repository->findByUriInLanguage($uri, $locale); }); }