TeachPlanController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\TeachPlan;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class TeachPlanController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new TeachPlan(), function (Grid $grid) {
  18. $grid->column('title');
  19. $grid->column('time');
  20. $grid->column('plan_type')->using(config('map.plan_type'));
  21. $grid->column('create_user_id')->using(config('map.teachers'));
  22. $grid->column('content');
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->equal('id');
  25. });
  26. });
  27. }
  28. /**
  29. * Make a show builder.
  30. *
  31. * @param mixed $id
  32. *
  33. * @return Show
  34. */
  35. protected function detail($id)
  36. {
  37. return Show::make($id, new TeachPlan(), function (Show $show) {
  38. $show->field('title');
  39. $show->field('time');
  40. $show->field('plan_type');
  41. $show->field('create_user_id');
  42. $show->field('content');
  43. $show->field('photos');
  44. $show->field('created_at');
  45. $show->field('updated_at');
  46. });
  47. }
  48. /**
  49. * Make a form builder.
  50. *
  51. * @return Form
  52. */
  53. protected function form()
  54. {
  55. return Form::make(new TeachPlan(), function (Form $form) {
  56. $form->select('plan_type')->options(config('map.plan_type'));
  57. $form->text('title');
  58. $form->textarea('content');
  59. $form->multipleImage('photos','上传照片')->saveAsJson();
  60. $form->file('pdf_file','点击上传文件')->help('上传格式为PDF,且大小不超过100MB');
  61. });
  62. }
  63. }