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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\User;
  4. use App\Common\UserStatus;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  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('agent:id,name'), function (Grid $grid) {
  19. $grid->disableRowSelector();
  20. $grid->disableCreateButton();
  21. $grid->disableActions();
  22. $grid->column('id')->sortable();
  23. $grid->column('agent.name', '所属代理商');
  24. $grid->column('avatar')->image(60, 60);
  25. $grid->column('mobile');
  26. $grid->column('nickname');
  27. $grid->column('status')->bool();
  28. $grid->column('verifier')->bool();
  29. $grid->column('created_at');
  30. $grid->column('updated_at');
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->panel();
  33. $filter->equal('id')->width(1);
  34. $filter->equal('mobile')->width(2);
  35. });
  36. });
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. *
  43. * @return Show
  44. */
  45. protected function detail($id)
  46. {
  47. return Show::make($id, new User(['agent:id,name']), function (Show $show) {
  48. $show->disableDeleteButton();
  49. $show->field('id');
  50. $show->field('agent.name', '代理商');
  51. $show->field('avatar')->image(80, 80);
  52. $show->field('mobile');
  53. $show->field('nickname');
  54. $show->field('status')->bool();
  55. $show->field('verifier')->bool();
  56. $show->field('created_at');
  57. $show->field('updated_at');
  58. });
  59. }
  60. /**
  61. * Make a form builder.
  62. *
  63. * @return Form
  64. */
  65. protected function form()
  66. {
  67. return Form::make(new User(), function (Form $form) {
  68. $form->disableDeleteButton();
  69. /*$form->display('id');
  70. $form->text('status');
  71. $form->text('verifier');*/
  72. })->deleting(function (Form $form) {
  73. return $form->response()->error('禁止删除');
  74. });
  75. }
  76. }