protected function bootObservers() { Block::observe(BlockObserver::class); Page::observe(PageObserver::class); BlockType::observe(DynamicObserver::class); PageType::observe(DynamicObserver::class); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * * @return mixed */ public function handle($request, Closure $next, $guard = null) { config()->set('auth.defaults.guard', 'soda'); //this is a work around for a laravel bug - the guard flicks back to the default when run through an auth Gate //so we need to temporarily set the guard to the incomming guard here instead. Block::disableDrafts(); BlockType::disableDrafts(); Page::disableDrafts(); PageType::disableDrafts(); return $next($request); }
/** * Show the page. * * @return Response */ public function getIndex(Request $request) { if ($request->input('id')) { $page = $this->model->find($request->input('id')); } else { $page = $this->model->getRoots()->first(); //todo: from application. if (!$page) { $page = Page::createRoot(); } } $page_types = PageType::get(); $pages = $page ? $page->collectDescendants()->orderBy('position')->get()->toTree() : []; $tree = $this->htmlTree($pages, $this->hint); return view('soda::page.index', ['hint' => $this->hint, 'pages' => $pages, 'tree' => $tree, 'page_types' => $page_types]); }