TreeRepository.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the dcat-admin.
  4. *
  5. * (c) jqh <841324345@qq.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Dcat\Admin\Contracts;
  11. interface TreeRepository
  12. {
  13. /**
  14. * @return string
  15. */
  16. public function getPrimaryKeyColumn();
  17. /**
  18. * @return string
  19. */
  20. public function getParentColumn();
  21. /**
  22. * Get title column.
  23. *
  24. * @return string
  25. */
  26. public function getTitleColumn();
  27. /**
  28. * Get order column name.
  29. *
  30. * @return string
  31. */
  32. public function getOrderColumn();
  33. /**
  34. * Save tree order from a tree like array.
  35. *
  36. * @param array $tree
  37. * @param int $parentId
  38. */
  39. public function saveOrder($tree = [], $parentId = 0);
  40. /**
  41. * Set query callback to model.
  42. *
  43. * @param \Closure|null $query
  44. *
  45. * @return $this
  46. */
  47. public function withQuery($queryCallback);
  48. /**
  49. * Format data to tree like array.
  50. *
  51. * @return array
  52. */
  53. public function toTree();
  54. }