海南旅游SAAS
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.

85 lines
2.2 KiB

4 years ago
  1. <?php
  2. namespace App\AdminAgent\Controllers;
  3. use App\AdminAgent\Repositories\Statement;
  4. use App\Common\StatementType;
  5. use App\Traits\DemandTraits;
  6. use Dcat\Admin\Admin;
  7. use Dcat\Admin\Form;
  8. use Dcat\Admin\Grid;
  9. use Dcat\Admin\Show;
  10. use Dcat\Admin\Http\Controllers\AdminController;
  11. class StatementController extends AdminController
  12. {
  13. /**
  14. * Make a grid builder.
  15. *
  16. * @return Grid
  17. */
  18. protected function grid()
  19. {
  20. return Grid::make(new Statement(), function (Grid $grid) {
  21. $grid->model()->where([
  22. 'access_id'=> Admin::user()->id,
  23. 'access_type' => DemandTraits::$col[0]
  24. ]);
  25. $grid->column('id')->sortable();
  26. $grid->column('price');
  27. $grid->column('type')->using(StatementType::array());
  28. $grid->column('created_at');
  29. $grid->column('updated_at')->sortable();
  30. $grid->disableCreateButton();
  31. $grid->disableActions();
  32. $grid->disableRowSelector();
  33. $grid->filter(function (Grid\Filter $filter) {
  34. $filter->equal('id');
  35. });
  36. });
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. *
  43. * @return Show
  44. */
  45. protected function detail($id)
  46. {
  47. return Show::make($id, new Statement(), function (Show $show) {
  48. $show->field('id');
  49. $show->field('price');
  50. $show->field('type');
  51. $show->field('user_id');
  52. $show->field('user_type');
  53. $show->field('access_id');
  54. $show->field('access_type');
  55. $show->field('created_at');
  56. $show->field('updated_at');
  57. });
  58. }
  59. /**
  60. * Make a form builder.
  61. *
  62. * @return Form
  63. */
  64. protected function form()
  65. {
  66. return Form::make(new Statement(), function (Form $form) {
  67. $form->display('id');
  68. $form->text('price');
  69. $form->text('type');
  70. $form->text('user_id');
  71. $form->text('user_type');
  72. $form->text('access_id');
  73. $form->text('access_type');
  74. $form->display('created_at');
  75. $form->display('updated_at');
  76. });
  77. }
  78. }