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

91 lines
2.4 KiB

  1. <?php
  2. namespace App\AdminAgent\Controllers;
  3. use App\AdminAgent\Repositories\Supplier;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class SupplierController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. //考虑到供应商表数据相对较少,故直接从供应商表查询,外加条件判断即可
  19. return Grid::make(new Supplier(), function (Grid $grid) {
  20. $grid->disableActions();
  21. $grid->disableCreateButton();
  22. $grid->disableRowSelector();
  23. $grid->disableFilterButton();
  24. $grid->model()->where(function ($query) {
  25. return $query->whereHas('AgentProductItem', function ($query) {
  26. return $query->where('agent_id', Admin::user()->id);
  27. });
  28. });
  29. $grid->column('id')->sortable();
  30. $grid->column('company_name');
  31. $grid->column('address');
  32. $grid->column('director');
  33. $grid->column('contact_phone');
  34. $grid->column('logo')->image('', 60, 60);
  35. $grid->column('avatar')->image('', 60, 60);
  36. $grid->column('license_pic')->image('', 60, 60);
  37. $grid->column('created_at', '入驻时间');
  38. $grid->filter(function (Grid\Filter $filter) {
  39. $filter->panel();
  40. $filter->equal('id');
  41. });
  42. });
  43. }
  44. /**
  45. * Make a show builder.
  46. *
  47. * @param mixed $id
  48. *
  49. * @return Show
  50. */
  51. protected function detail($id)
  52. {
  53. return Show::make($id, new Supplier(), function (Show $show) {
  54. $show->field('id');
  55. /*$show->field('name');
  56. $show->field('company_name');
  57. $show->field('address');
  58. $show->field('director');
  59. $show->field('contact_phone');
  60. $show->field('logo');
  61. $show->field('avatar');
  62. $show->field('license_pic');
  63. $show->field('created_at');
  64. $show->field('updated_at');*/
  65. });
  66. }
  67. /**
  68. * Make a form builder.
  69. *
  70. * @return Form
  71. */
  72. protected function form()
  73. {
  74. return Form::make(new Supplier(), function (Form $form) {
  75. $form->display('id');
  76. })->saving(function (Form $form) {
  77. $form->response()->error('操作禁止');
  78. })->deleting(function (Form $form) {
  79. $form->response()->error('操作禁止');
  80. });
  81. }
  82. }