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

86 lines
2.3 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('created_at');
  27. $grid->column('updated_at')->sortable();
  28. $grid->disableDeleteButton();
  29. $grid->disableEditButton();
  30. $grid->disableQuickEditButton();
  31. $grid->disableViewButton();
  32. $grid->disableCreateButton();
  33. $grid->disableActions();
  34. $grid->filter(function (Grid\Filter $filter) {
  35. $filter->equal('id');
  36. });
  37. });
  38. }
  39. /**
  40. * Make a show builder.
  41. *
  42. * @param mixed $id
  43. *
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. return Show::make($id, new DemandBidding(), function (Show $show) {
  49. $show->field('id');
  50. $show->field('price');
  51. $show->field('comment');
  52. $show->field('created_at');
  53. $show->field('updated_at');
  54. });
  55. }
  56. /**
  57. * Make a form builder.
  58. *
  59. * @return Form
  60. */
  61. protected function form()
  62. {
  63. return Form::make(new DemandBidding(), function (Form $form) {
  64. $form->display('id');
  65. $form->text('price');
  66. $form->text('comment');
  67. $form->hidden('demand_id')->value(request('demand_id',0));
  68. $form->hidden('bidding_user_type');
  69. $form->hidden('bidding_user_id');
  70. $form->saving(function (Form $form) {
  71. // 判断是否是新增操作
  72. if ($form->isCreating()) {
  73. //发布人身份
  74. $form->bidding_user_type = 'App\models\Agent';
  75. $form->bidding_user_id = Admin::user()->id;
  76. }
  77. });
  78. });
  79. }
  80. }