/** * Handle the command. * * @param Guard $auth */ public function handle(Guard $auth) { /* @var UserInterface|null $user */ $user = $auth->user(); /* @var PageInterface $page */ foreach ($this->pages as $key => $page) { $roles = $page->getAllowedRoles(); /** * If there are role restrictions * but no user is signed in then * we can't authorize anything! */ if (!$roles->isEmpty() && !$user) { $this->pages->forget($key); continue; } /** * If there are role restrictions * and the user does not belong to * any of them then don't show it. */ if (!$roles->isEmpty() && !$user->hasAnyRole($roles)) { $this->pages->forget($key); continue; } } }
/** * Handle the command. */ public function handle(ViewTemplate $template) { if (!($current = $this->pages->current())) { return; } if (!$current->getParentId()) { return; } /* @var PageInterface $page */ foreach ($this->pages as $page) { /** * Already flagged. */ if ($page->isActive() || $page->isCurrent()) { continue; } /** * Set active if the direct * parent of current page. */ if ($page->getId() == $current->getParentId()) { $page->setActive(true); } /** * If the active page is in the children * of this page then mark it active too. */ if (!$this->pages->children($page)->active()->isEmpty()) { $page->setActive(true); $this->dispatch(new SetActivePages($this->pages)); } } }
/** * Handle the command. */ public function handle() { /* @var PageInterface|EloquentModel $page */ foreach ($this->pages as $page) { $page->setRelation('children', $this->pages->children($page)); } }
/** * Handle the command. */ public function handle(ViewTemplate $template) { /* @var PageInterface $page */ if (!($page = $template->get('page'))) { return; } /* @var PageInterface $current */ $current = $this->pages->find($page->getId()); $current->setCurrent(true); }
/** * Handle the command. */ public function handle() { /* @var PageInterface|EloquentModel $page */ foreach ($this->pages as $page) { /* @var PageInterface $parent */ if (($id = $page->getParentId()) && ($parent = $this->pages->find($id))) { $page->setRelation('parent', $parent); } } }