LiveRoomController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\LiveRoom;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class LiveRoomController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new LiveRoom(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('name');
  20. $grid->column('img')->image(config("filesystems.disks.cosv5.url"),60,60);
  21. $grid->column('short_name');
  22. $grid->column('medal_name');
  23. $grid->column('room_id');
  24. $grid->column('sort')->editable(true);
  25. $grid->column('is_show_share')->using(['隐藏','显示']);
  26. // $grid->column('created_at');
  27. $grid->column('updated_at')->sortable();
  28. $grid->enableDialogCreate();
  29. $grid->setDialogFormDimensions('50%', '60%');
  30. $grid->withBorder();
  31. $grid->actions(function (Grid\Displayers\Actions $actions) {
  32. $actions->quickEdit(true);
  33. $actions->disableEdit();
  34. $actions->disableView();
  35. });
  36. $grid->model()->orderBy("sort","asc")->orderBy("id","asc");
  37. });
  38. }
  39. /**
  40. * Make a show builder.
  41. *
  42. * @param mixed $id
  43. *
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. return Show::make($id, new LiveRoom(), function (Show $show) {
  49. $show->field('id');
  50. $show->field('name');
  51. $show->field('img');
  52. $show->field('short_name');
  53. $show->field('room_id');
  54. $show->field('sort');
  55. $show->field('is_show_share');
  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 LiveRoom(), function (Form $form) {
  68. // $form->display('id');
  69. $form->text('name')->required();
  70. $form->image('img')->autoUpload()->removable(false)->autoSave(false)->uniqueName()->required();
  71. $form->text('short_name')->required();
  72. $form->text('medal_name');
  73. $form->text('room_id')->required();
  74. $form->number('sort')->default(0)->help("显示的顺序,默认从小到大显示");
  75. $form->switch('is_show_share')->help("用来控制在H5页面的试衣间上传皮肤后的弹窗中是否显示");
  76. });
  77. }
  78. }