/**
  * @param PageRepository $pageRepository
  *
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getSettings(PageRepository $pageRepository)
 {
     $pageId = $this->getParameter('pid');
     $behavior = $this->getRequiredParameter('behavior');
     if (!is_null($behavior = BehaviorManager::load($behavior))) {
         $page = $pageRepository->findOrFail($pageId);
         if ($page->hasBehavior()) {
             $behavior->setPage($page);
         }
     }
     return $this->setContent($behavior->getSettings()->render());
 }
 /**
  * @param PageRepository $repository
  */
 public function getSearch(PageRepository $repository)
 {
     $query = trim($this->getRequiredParameter('search'));
     $pages = $repository->searchByKeyword($query);
     $children = [];
     foreach ($pages as $page) {
         $page->isExpanded = false;
         $page->hasChildren = false;
         $children[] = $page;
     }
     $this->setContent(view('pages::pages.children', ['children' => $children, 'level' => 0]));
 }
 /**
  * @param WidgetRepository $repository
  * @param PageRepository   $pageRepository
  * @param int          $id
  */
 public function getLocation(WidgetRepository $repository, PageRepository $pageRepository, $id)
 {
     $widget = $repository->findOrFail($id);
     list($widgetBlocks, $blocksToExclude) = $widget->getLocations();
     $pages = $pageRepository->getSitemap(true);
     $this->breadcrumbs->add($widget->getType())->add($widget->name, route('backend.widget.edit', [$widget]));
     $this->setTitle(trans($this->wrapNamespace('core.title.location'), ['name' => $widget->name]));
     $layoutBlocks = (new LayoutBlock())->getBlocksGroupedByLayouts();
     $this->setContent('widgets.location', compact('widget', 'pages', 'widgetBlocks', 'blocksToExclude', 'layoutBlocks'));
 }
 /**
  * @param PageRepository $repository
  * @param int            $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postDelete(PageRepository $repository, $id)
 {
     /** @var Page $page */
     $page = $repository->delete($id);
     return $this->smartRedirect()->with('success', trans('pages::core.messages.deleted', ['title' => $page->title]));
 }