/**
  * @param SectionRepository $repository
  */
 public function addSectionToFolder(SectionRepository $repository)
 {
     $sectionId = $this->getRequiredParameter('section_id');
     $folderId = $this->getRequiredParameter('folder_id');
     $repository->findOrFail($sectionId)->update(['folder_id' => $folderId]);
     $this->setContent(true);
 }
 /**
  * @param SectionRepository $sectionRepository
  * @param FieldRepository   $repository
  * @param int           $dsId
  */
 public function getCreate(SectionRepository $sectionRepository, FieldRepository $repository, $dsId)
 {
     $section = $sectionRepository->findOrFail($dsId);
     $this->breadcrumbs->add($section->getName(), route('backend.datasource.list', $section->getId()))->add('Edit section', route('backend.datasource.edit', $section->getId()));
     $this->setTitle('Create field');
     $this->templateScripts['SECTION_ID'] = $dsId;
     $this->setContent('field.create', ['field' => $repository->instance(), 'section' => $section, 'sections' => $repository->getSectionsForSelect()]);
 }
 /**
  * @param SectionRepository $repository
  * @param int               $sectionId
  *
  * @return $this
  */
 public function getRemove(SectionRepository $repository, $sectionId)
 {
     $repository->delete($sectionId);
     return redirect()->route('backend.datasource.list')->withCookie(cookie()->forget(static::DS_COOKIE_NAME));
 }
 /**
  * @param int         $sectionId
  * @param string|null $keyword
  * @param array       $exclude
  *
  * @return array|static[]
  */
 public function findByKeyword($sectionId, $keyword = null, array $exclude = [])
 {
     /** @var SectionInterface $section */
     $section = $this->section->findOrFail($sectionId);
     return \DB::table($section->getSectionTableName())->select('*')->selectRaw("{$section->getDocumentPrimaryKey()} as id")->selectRaw("{$section->getDocumentTitleKey()} as text")->where($section->getDocumentTitleKey(), 'like', '%' . $keyword . '%')->whereNotIn($section->getDocumentPrimaryKey(), $exclude)->limit(10)->get();
 }
 /**
  * @param SectionRepository $repository
  *
  * @return JsonResponse
  */
 public function getHeadline(SectionRepository $repository)
 {
     $sectionId = $this->getRequiredParameter('section_id');
     return $repository->findOrFail($sectionId)->getHeadline()->JsonResponse();
 }