Repository.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. use Dcat\Admin\Form;
  12. use Dcat\Admin\Grid;
  13. use Dcat\Admin\Show;
  14. use Illuminate\Support\Collection;
  15. interface Repository
  16. {
  17. /**
  18. * 获取主键名称.
  19. *
  20. * @return string
  21. */
  22. public function getKeyName();
  23. /**
  24. * 获取创建时间字段.
  25. *
  26. * @return string
  27. */
  28. public function getCreatedAtColumn();
  29. /**
  30. * 获取更新时间字段.
  31. *
  32. * @return string
  33. */
  34. public function getUpdatedAtColumn();
  35. /**
  36. * 是否使用软删除.
  37. *
  38. * @return bool
  39. */
  40. public function isSoftDeletes();
  41. /**
  42. * 获取Grid表格数据.
  43. *
  44. * @param Grid\Model $model
  45. *
  46. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|Collection|array
  47. */
  48. public function get(Grid\Model $model);
  49. /**
  50. * 获取编辑页面数据.
  51. *
  52. * @param Form $form
  53. *
  54. * @return array|\Illuminate\Contracts\Support\Arrayable
  55. */
  56. public function edit(Form $form);
  57. /**
  58. * 获取详情页面数据.
  59. *
  60. * @param Show $show
  61. *
  62. * @return array|\Illuminate\Contracts\Support\Arrayable
  63. */
  64. public function detail(Show $show);
  65. /**
  66. * 新增记录.
  67. *
  68. * @param Form $form
  69. *
  70. * @return mixed
  71. */
  72. public function store(Form $form);
  73. /**
  74. * 查询更新前的行数据.
  75. *
  76. * @param Form $form
  77. *
  78. * @return array|\Illuminate\Contracts\Support\Arrayable
  79. */
  80. public function updating(Form $form);
  81. /**
  82. * 更新数据.
  83. *
  84. * @param Form $form
  85. *
  86. * @return bool
  87. */
  88. public function update(Form $form);
  89. /**
  90. * 删除数据.
  91. *
  92. * @param Form $form
  93. * @param array $deletingData
  94. *
  95. * @return mixed
  96. */
  97. public function delete(Form $form, array $deletingData);
  98. /**
  99. * 查询删除前的行数据.
  100. *
  101. * @param Form $form
  102. *
  103. * @return array|\Illuminate\Contracts\Support\Arrayable
  104. */
  105. public function deleting(Form $form);
  106. }