WxShopAddressController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Repositories\Shop\WxShopAddress;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxShopAddressController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxShopAddress(['user']), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->quickSearch(['id', 'user.user_name', 'name', 'mobile', 'province', 'city', 'county', 'adds'])->placeholder('搜索地址ID,用户名字,名称,手机号,省份等...')->width(30);
  20. $grid->model()->orderBy('id', 'desc');
  21. $grid->column('id')->sortable();
  22. $grid->column('user.user_avatar','头像')->image('',30,30);
  23. $grid->column('user.user_name','用户');
  24. $grid->column('name');
  25. $grid->column('mobile');
  26. $grid->column('province');
  27. $grid->column('city');
  28. $grid->column('county');
  29. $grid->column('adds');
  30. // $grid->column('user_id');
  31. $grid->column('is_check')->using([0=>'否',1=>'是'])->label([
  32. 0=>'default',
  33. 1=>'green'
  34. ]);
  35. $grid->column('state')->using([0 => '正常', 1 => '用户删除'])->label([
  36. 0 => 'primary',
  37. 1 => 'default',
  38. ]);
  39. $grid->column('created_at');
  40. // $grid->column('updated_at')->sortable();
  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 WxShopAddress(), function (Show $show) {
  56. $show->field('id');
  57. $show->field('name');
  58. $show->field('mobile');
  59. $show->field('province');
  60. $show->field('city');
  61. $show->field('county');
  62. $show->field('adds');
  63. $show->field('user_id');
  64. $show->field('is_check');
  65. $show->field('state');
  66. $show->field('created_at');
  67. $show->field('updated_at');
  68. });
  69. }
  70. /**
  71. * Make a form builder.
  72. *
  73. * @return Form
  74. */
  75. protected function form()
  76. {
  77. return Form::make(new WxShopAddress(), function (Form $form) {
  78. $form->display('id');
  79. $form->text('name');
  80. $form->text('mobile');
  81. $form->text('province');
  82. $form->text('city');
  83. $form->text('county');
  84. $form->text('adds');
  85. $form->text('user_id');
  86. $form->text('is_check');
  87. $form->text('state');
  88. $form->deleting(function (Form $form){
  89. global $__MINI_GLOBAL_TENANT_ID__;
  90. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  91. return $form->response()->error('权限不足,不可以删除其他分站对象');
  92. }
  93. });
  94. });
  95. }
  96. }