middleware("auth"); $this->middleware([ "lang" ]); } public function index() { $perPage = 5; //All news $newsCollection = News::query()->orderBy('id', 'desc')->paginate($perPage); //Runs through all the news and deletes the old stuff foreach ($newsCollection as $new) { if($new->type_id == 3) if(Event::query()->where('id', '=', $new->arrangement_id)->first() == null) $new->delete(); } //Return either the admin or app index page without the old news if(auth()->user()->can('admin.panel.show')) { if(Response::detect("root.index")->name() == "admin.root.index") return view("admin.root.index"); else { $news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get(); return view("app.root.index", ["news" => $news]); } } else { $news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get(); return Response::detect('root.index', ["news" => $news]); } } }