path(); $this->page = ModelsPage::where('slug', $slug)->firstOrFail(); // Pagina actief ja of nee if (!$this->page->is_active) { abort(404); } // check voor expire if ($this->page->expires_at && now()->greaterThan($this->page->expires_at)) { abort(404); } // Toegangscontrole switch ($this->page->visibility) { case 'admins': if (!Auth::check() || is_null(Auth::user()->role)) { abort(404); } break; case 'customers': if (!Auth::check() || !is_null(Auth::user()->role)) { abort(404); } break; case 'guests': if (Auth::check()) { abort(404); } break; case 'logged-in': if (!Auth::check()) { abort(404); } break; case 'everyone': default: // iedereen break; } // Pageviews PageView::create([ 'page_id' => $this->page->id, 'ip_address' => Request::ip(), 'user_agent' => Request::header('User-Agent'), 'viewed_at' => now(), ]); } public function render() { return view('custompages::show', [ 'page' => $this->page, ])->layout('layouts.app', [ 'title' => $this->page->meta_title ?? $this->page->title, 'description' => $this->page->meta_description ?? '', 'image' => $this->page->meta_image ?? null, 'color' => $this->page->meta_color ?? null, 'favicon' => $this->page->meta_favicon ?? null, ]); } }