链街Dcat后台
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.

108 lines
3.3 KiB

  1. <?php
  2. namespace App\Admin\Controllers\v3;
  3. use App\Admin\Repositories\v3\StoreUser;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Controllers\AdminController;
  8. use App\Models\v3\Store as StoreModel;
  9. use App\Models\v3\StoreUser as StoreUserModel;
  10. class StoreUserController extends AdminController
  11. {
  12. /**
  13. * Make a grid builder.
  14. *
  15. * @return Grid
  16. */
  17. protected function grid()
  18. {
  19. return Grid::make(new StoreUser(), function (Grid $grid) {
  20. // 店铺
  21. $storeList = StoreModel::getStoreArray();
  22. // 账号类型
  23. $categoryList = StoreUserModel::$_USER_CATEGORY;
  24. // 注册类型
  25. $typeList = StoreUserModel::$_USER_CATEGORY;
  26. $grid->column('id')->sortable();
  27. $grid->column('store_id')->display(function($storeId) use($storeList){
  28. return isset($storeList[$storeId])?$storeList[$storeId]:'';
  29. });
  30. $grid->column('username');
  31. $grid->column('user_category')->display(function($userCategory) use($categoryList){
  32. return isset($categoryList[$userCategory])?$categoryList[$userCategory]:'';
  33. });
  34. $grid->column('register_type')->display(function($registerType) use($typeList){
  35. return isset($typeList[$registerType])?$typeList[$registerType]:'';
  36. });
  37. $grid->column('status');
  38. $grid->column('join_ip');
  39. $grid->column('last_visit_time');
  40. $grid->column('last_ip');
  41. $grid->model()->orderBy('id', 'desc');
  42. // 每页10条
  43. $grid->paginate(10);
  44. $grid->filter(function (Grid\Filter $filter) use($categoryList){
  45. unset($categoryList[0]);
  46. $filter->equal('id');
  47. $filter->equal('user_category')->select($categoryList);
  48. });
  49. });
  50. }
  51. /**
  52. * Make a show builder.
  53. *
  54. * @param mixed $id
  55. *
  56. * @return Show
  57. */
  58. protected function detail($id)
  59. {
  60. return Show::make($id, new StoreUser(), function (Show $show) {
  61. $show->field('id');
  62. $show->field('store_id');
  63. $show->field('username');
  64. $show->field('user_category');
  65. $show->field('register_type');
  66. $show->field('status');
  67. $show->field('join_ip');
  68. $show->field('last_visit_time');
  69. $show->field('last_ip');
  70. $show->field('created_at');
  71. $show->field('updated_at');
  72. });
  73. }
  74. /**
  75. * Make a form builder.
  76. *
  77. * @return Form
  78. */
  79. protected function form()
  80. {
  81. return Form::make(new StoreUser(), function (Form $form) {
  82. // 店铺
  83. $storeList = StoreModel::getStoreArray();
  84. // 账号类型
  85. $categoryList = StoreUserModel::$_USER_CATEGORY;
  86. unset($categoryList[0]);
  87. $form->display('id');
  88. $form->select('store_id')->options($storeList);
  89. $form->text('username');
  90. $form->password('password_');
  91. $form->password('password_confirm')->same('password');
  92. $form->select('user_category')->options($categoryList);
  93. $form->hidden('register_type')->default(5);
  94. });
  95. }
  96. }