Example #1
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->page->aclEnabled()) {
         if (!$this->guard->check()) {
             return new RedirectResponse(route('login'));
         }
         if ($this->gate->denies('view', $this->page)) {
             abort(403);
         }
     }
     return $next($request);
 }
Example #2
0
 public function handle()
 {
     $attrs = [];
     if ($this->parent) {
         $attrs += ['parent_id' => $this->parent->getId(), 'visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav(), 'children_visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'children_visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav(), 'enable_acl' => $this->parent->aclEnabled()];
     }
     $page = PageFacade::create($attrs);
     $page->addVersion(['template_id' => $this->parent ? $this->parent->getDefaultChildTemplateId() : null, 'title' => $this->title, 'embargoed_until' => time()]);
     if ($this->parent) {
         $groupIds = $this->parent->getAclGroupIds();
         foreach ($groupIds as $groupId) {
             $page->addAclGroupId($groupId);
         }
     }
     Event::fire(new PageWasCreated($page, $this->parent));
     return $page;
 }