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

105 lines
2.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminAgent\Controllers;
  3. use App\AdminAgent\Repositories\DemandBidding;
  4. use App\Traits\DemandTraits;
  5. use Dcat\Admin\Admin;
  6. use Dcat\Admin\Form;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Show;
  9. use Dcat\Admin\Http\Controllers\AdminController;
  10. use http\Env\Request;
  11. use Illuminate\Support\Arr;
  12. class DemandBiddingController extends AdminController
  13. {
  14. /**
  15. * Make a grid builder.
  16. *
  17. * @return Grid
  18. */
  19. protected function grid()
  20. {
  21. return Grid::make(new DemandBidding(['demand']), function (Grid $grid) {
  22. $grid->model()->where(['bidding_user_id' => Admin::user()->id,'bidding_user_type' => Arr::first(DemandTraits::$col)]);
  23. $grid->column('id')->sortable();
  24. $grid->column('price');
  25. $grid->column('comment');
  26. $grid->column('demand.title','竞拍标题');
  27. $grid->column('demand.comment','竞拍内容')
  28. ->display('查看')
  29. ->modal('详情',function ($modal) {
  30. $modal->xl();
  31. return $this->demand->comment;
  32. });
  33. $grid->column('state','状态')->using(DemandTraits::$biddingState)->dot(
  34. [
  35. 'yellow',
  36. 'success',
  37. 'danger',
  38. ]
  39. );
  40. $grid->column('created_at');
  41. $grid->column('updated_at')->sortable();
  42. $grid->disableDeleteButton();
  43. $grid->disableEditButton();
  44. $grid->disableQuickEditButton();
  45. $grid->disableViewButton();
  46. $grid->disableCreateButton();
  47. $grid->disableActions();
  48. $grid->filter(function (Grid\Filter $filter) {
  49. $filter->equal('id');
  50. });
  51. });
  52. }
  53. /**
  54. * Make a show builder.
  55. *
  56. * @param mixed $id
  57. *
  58. * @return Show
  59. */
  60. protected function detail($id)
  61. {
  62. return Show::make($id, new DemandBidding(), function (Show $show) {
  63. $show->field('id');
  64. $show->field('price');
  65. $show->field('comment');
  66. $show->field('created_at');
  67. $show->field('updated_at');
  68. });
  69. }
  70. /**
  71. * Make a form builder.
  72. *
  73. * @return Form
  74. */
  75. protected function form()
  76. {
  77. return Form::make(new DemandBidding(), function (Form $form) {
  78. $form->disableEditingCheck();
  79. $form->disableCreatingCheck();
  80. $form->disableViewCheck();
  81. $form->display('id');
  82. $form->text('price')->required();
  83. $form->textarea('comment')->required();
  84. $form->hidden('demand_id')->value(request('demand_id',0));
  85. $form->hidden('bidding_user_type');
  86. $form->hidden('bidding_user_id');
  87. $form->saving(function (Form $form) {
  88. // 判断是否是新增操作
  89. if ($form->isCreating()) {
  90. //发布人身份
  91. $form->bidding_user_type = DemandTraits::$col[0];
  92. $form->bidding_user_id = Admin::user()->id;
  93. }
  94. $form->response()->success('操作成功')->redirect('demand_bidding');
  95. });
  96. });
  97. }
  98. }