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

111 lines
3.1 KiB

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