链街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.

113 lines
3.3 KiB

  1. <?php
  2. namespace App\Admin\Controllers\v3;
  3. use App\Admin\Repositories\v3\User;
  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\User as UserModel;
  9. class UserController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new User(), function (Grid $grid) {
  19. $grid->column('id')->sortable();
  20. $grid->column('avatar')->image('',50);
  21. $grid->column('nick_name');
  22. $grid->column('openid');
  23. $grid->column('unionid');
  24. $grid->column('real_name')->editable();
  25. $grid->column('tel');
  26. $grid->column('gender_text');
  27. $grid->column('status')->using(UserModel::$_STATUS)->label(config('label.status_label'));
  28. $grid->filter(function (Grid\Filter $filter) {
  29. $filter->equal('id');
  30. $filter->like('nick_name');
  31. $filter->like('real_name');
  32. });
  33. $grid->model()->orderBy('id','desc');
  34. // 每页10条
  35. $grid->paginate(10);
  36. $grid->disableCreateButton();
  37. $grid->disableDeleteButton();
  38. $grid->disableEditButton();
  39. });
  40. }
  41. /**
  42. * Make a show builder.
  43. *
  44. * @param mixed $id
  45. *
  46. * @return Show
  47. */
  48. protected function detail($id)
  49. {
  50. return Show::make($id, new User(), function (Show $show) {
  51. $show->field('id');
  52. $show->field('nick_name');
  53. $show->field('avatar')->image();
  54. $show->field('openid');
  55. $show->field('real_name');
  56. $show->field('tel');
  57. $show->field('unionid');
  58. $show->field('country');
  59. $show->field('province');
  60. $show->field('city');
  61. $show->field('gender_text');
  62. $show->field('language');
  63. $show->field('status_text');
  64. $show->field('created_at');
  65. $show->field('updated_at');
  66. $show->panel()->tools(function ($tools) {
  67. $tools->disableEdit();
  68. // $tools->disableList();
  69. $tools->disableDelete();
  70. // 显示快捷编辑按钮
  71. // $tools->showQuickEdit();
  72. });
  73. });
  74. }
  75. /**
  76. * Make a form builder.
  77. *
  78. * @return Form
  79. */
  80. protected function form()
  81. {
  82. return Form::make(new User(), function (Form $form) {
  83. $form->hidden('id');
  84. $form->text('nick_name');
  85. $form->image('avatar');
  86. $form->text('openid');
  87. $form->text('real_name');
  88. $form->tel('tel');
  89. $form->text('unionid');
  90. $form->text('status');
  91. $form->text('country');
  92. $form->text('province');
  93. $form->text('city');
  94. $form->radio('gender')->options(UserModel::$_GENDER);
  95. $form->text('language');
  96. $form->disableResetButton();
  97. $form->disableViewCheck();
  98. $form->disableEditingCheck();
  99. $form->disableCreatingCheck();
  100. $form->disableDeleteButton();
  101. });
  102. }
  103. }