AnchorController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Anchor;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Admin;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. use Illuminate\Support\Facades\Log;
  10. use function PHPSTORM_META\type;
  11. class AnchorController extends AdminController
  12. {
  13. /**
  14. * Make a grid builder.
  15. *
  16. * @return Grid
  17. */
  18. protected function grid()
  19. {
  20. return Grid::make(new Anchor(), function (Grid $grid) {
  21. $grid->column('id')->sortable();
  22. $grid->column('name');
  23. $grid->column('status')->using([
  24. 1 => '正常',
  25. 2 => '封禁',
  26. 9 => '删除',
  27. ])->label([
  28. 1 => Admin::color()->success(80),
  29. 2 => Admin::color()->danger(60),
  30. 9 => Admin::color()->warning(60),
  31. ]);
  32. // $grid->column('live_room_id');
  33. // $grid->column('admin_users_id');
  34. // $grid->column('created_at');
  35. // $grid->column('updated_at')->sortable();
  36. $grid->fixColumns(0, -1); //设置固定栏目
  37. $grid->disableViewButton(); //禁用详情
  38. $grid->disableBatchDelete(); //禁用批量删除
  39. $grid->disableDeleteButton(); //禁用删除
  40. $grid->filter(function (Grid\Filter $filter) {
  41. $filter->equal('id');
  42. });
  43. });
  44. }
  45. /**
  46. * Make a show builder.
  47. *
  48. * @param mixed $id
  49. *
  50. * @return Show
  51. */
  52. protected function detail($id)
  53. {
  54. return Show::make($id, new Anchor(), function (Show $show) {
  55. $show->field('id');
  56. $show->field('status');
  57. $show->field('live_room_id');
  58. $show->field('name');
  59. $show->field('admin_users_id');
  60. $show->field('created_at');
  61. $show->field('updated_at');
  62. });
  63. }
  64. /**
  65. * Make a form builder.
  66. *
  67. * @return Form
  68. */
  69. protected function form()
  70. {
  71. return Form::make(new Anchor(), function (Form $form) {
  72. // $form->display('id');
  73. // $form->divider('目前只支持管理员修改,无权限请勿修改');
  74. // $form->text('password', '密码')->required();
  75. $form->text('name');
  76. $form->select('status', '状态')->options([
  77. 1 => '正常',
  78. 2 => '封禁',
  79. // 9 => '删除',
  80. ])->required();
  81. $form->text('app_id')->help('请勿随意修改,否则会导致无法提单');
  82. $form->text('app_secret')->help('请勿随意修改,否则会导致无法提单');
  83. // $form->saving(function (Form $form) {
  84. // if($form->password == "123"){
  85. // // return 1;
  86. // }
  87. // });
  88. $form->saved(function (Form $form) {
  89. Log::info('修改主播:' . $form->name);
  90. Log::info(json_encode($form->model(), JSON_UNESCAPED_UNICODE));
  91. });
  92. // $form->text('live_room_id');
  93. // $form->text('admin_users_id');
  94. // $form->display('created_at');
  95. // $form->display('updated_at');
  96. });
  97. }
  98. }