You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

5 years ago
  1. <?php
  2. namespace App\Repositories;
  3. use SuperGear\Directus\Repositories\RepositoryAbstract;
  4. /**
  5. * request page items from directus
  6. *
  7. * @author Björn Hase
  8. * @license http://opensource.org/licenses/MIT The MIT License
  9. * @link https://gitlab.tentakelfabrik.de/super-gear/directus GitHub Repository
  10. */
  11. class PageRepository extends RepositoryAbstract
  12. {
  13. /** name of the collection */
  14. protected $name = 'page';
  15. /**
  16. * find single page with a slug,
  17. * page must be published
  18. *
  19. * @param string $slug
  20. * @return array
  21. */
  22. public function findOneBySlug($slug)
  23. {
  24. return $this->itemCollection->findOne($this->name, [
  25. 'filter[slug][eq]' => $slug,
  26. 'filter[status][eq]' => 'published'
  27. ]);
  28. }
  29. /**
  30. * find single page with a slug,
  31. * page must be published
  32. *
  33. * @param string $slug
  34. * @return array
  35. */
  36. public function findByView($view)
  37. {
  38. return $this->itemCollection->find($this->name, [
  39. 'filter[view][eq]' => $view,
  40. 'filter[status][eq]' => 'published'
  41. ]);
  42. }
  43. }