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

97 lines
2.6 KiB

  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(), 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('state','状态')->using(DemandTraits::$biddingState)->dot(
  27. [
  28. 'yellow',
  29. 'success',
  30. 'danger',
  31. ]
  32. );
  33. $grid->column('created_at');
  34. $grid->column('updated_at')->sortable();
  35. $grid->disableDeleteButton();
  36. $grid->disableEditButton();
  37. $grid->disableQuickEditButton();
  38. $grid->disableViewButton();
  39. $grid->disableCreateButton();
  40. $grid->disableActions();
  41. $grid->filter(function (Grid\Filter $filter) {
  42. $filter->equal('id');
  43. });
  44. });
  45. }
  46. /**
  47. * Make a show builder.
  48. *
  49. * @param mixed $id
  50. *
  51. * @return Show
  52. */
  53. protected function detail($id)
  54. {
  55. return Show::make($id, new DemandBidding(), function (Show $show) {
  56. $show->field('id');
  57. $show->field('price');
  58. $show->field('comment');
  59. $show->field('created_at');
  60. $show->field('updated_at');
  61. });
  62. }
  63. /**
  64. * Make a form builder.
  65. *
  66. * @return Form
  67. */
  68. protected function form()
  69. {
  70. return Form::make(new DemandBidding(), function (Form $form) {
  71. $form->disableEditingCheck();
  72. $form->disableCreatingCheck();
  73. $form->disableViewCheck();
  74. $form->display('id');
  75. $form->text('price');
  76. $form->textarea('comment');
  77. $form->hidden('demand_id')->value(request('demand_id',0));
  78. $form->hidden('bidding_user_type');
  79. $form->hidden('bidding_user_id');
  80. $form->saving(function (Form $form) {
  81. // 判断是否是新增操作
  82. if ($form->isCreating()) {
  83. //发布人身份
  84. $form->bidding_user_type = DemandTraits::$col[0];
  85. $form->bidding_user_id = Admin::user()->id;
  86. }
  87. $form->response()->success('操作成功')->redirect('demand_bidding');
  88. });
  89. });
  90. }
  91. }