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

99 lines
2.7 KiB

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