BabysittingController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Babysitting;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class BabysittingController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Babysitting(), function (Grid $grid) {
  18. $grid->column('student_id')->using(config('map.students'));
  19. $grid->column('look_time');
  20. $grid->column('looker')->using(config('map.teachers'));
  21. $grid->column('is_publish')->using([0=>'否',1=>'是']);
  22. $grid->disableViewButton();
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->panel();
  25. $filter->equal('student_id')->select(config('map.students'))->width(4);
  26. });
  27. });
  28. }
  29. /**
  30. * Make a show builder.
  31. *
  32. * @param mixed $id
  33. *
  34. * @return Show
  35. */
  36. protected function detail($id)
  37. {
  38. return Show::make($id, new Babysitting(), function (Show $show) {
  39. $show->field('id');
  40. $show->field('look_time');
  41. $show->field('is_share_to_parents');
  42. $show->field('looker');
  43. $show->field('title');
  44. $show->field('student_id');
  45. $show->field('desc');
  46. $show->field('photos');
  47. $show->field('videos');
  48. $show->field('choose_ability');
  49. $show->column('is_publish');
  50. $show->field('effective_learn_characteristics');
  51. $show->field('next_teach_activity_plan');
  52. $show->field('look_bg');
  53. $show->field('created_at');
  54. $show->field('updated_at');
  55. });
  56. }
  57. /**
  58. * Make a form builder.
  59. *
  60. * @return Form
  61. */
  62. protected function form()
  63. {
  64. return Form::make(new Babysitting(), function (Form $form) {
  65. $form->row(function (Form\Row $row) {
  66. $row->width(2)->datetime('look_time')->required();
  67. $row->width(1)->switch('is_share_to_parents');
  68. $row->width(1)->select('looker')->options(config('map.teachers'))->disable();
  69. });
  70. $form->row(function (Form\Row $row) {
  71. $row->text('title')->placeholder('请输入标题')->required();
  72. });
  73. $form->row(function (Form\Row $row) {
  74. $row->select('student_id')->options(config('map.students'))->placeholder('请选择学生')->required();
  75. });
  76. $form->row(function (Form\Row $row) {
  77. $row->textarea('desc')->placeholder('请输入描述')->required();
  78. });
  79. $form->row(function (Form\Row $row) use($form) {
  80. $row->width(3)->multipleImage('photos');
  81. $row->width(3)->file('videos');
  82. // $row->radio('type')
  83. // ->when(1,function(Form $form){
  84. // })
  85. // ->when(2,function(Form $form){
  86. // })
  87. // ->options([1=>'上传图片',2=>'上传视频'])
  88. // ->default(1);
  89. });
  90. $form->row(function (Form\Row $row) {
  91. $row->select('choose_ability')->options(config('map.students'))->placeholder('请选择能力')->required();
  92. });
  93. $form->row(function (Form\Row $row) {
  94. $row->select('effective_learn_characteristics')->options(config('map.students'))->placeholder('请选有效学习特征')->required();
  95. });
  96. $form->text('is_publish');
  97. $form->row(function (Form\Row $row) {
  98. $row->textarea('next_teach_activity_plan')->placeholder('请输入下一步教学活动安排')->required();
  99. });
  100. $form->row(function (Form\Row $row) {
  101. $row->textarea('look_bg')->placeholder('请输入观察背景')->required();
  102. });
  103. $form->disableViewButton();
  104. });
  105. }
  106. }