StudentController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Student;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class StudentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Student(), function (Grid $grid) {
  18. //$grid->column('id')->sortable();
  19. $grid->column('name');
  20. $grid->column('sex')->using(config('map.sex'));
  21. $grid->column('month_old');
  22. $grid->column('join_garden_time');
  23. $grid->column('parent_name');
  24. $grid->column('class_id')->using(config('map.class'));
  25. $grid->disableCreateButton();
  26. $grid->disableViewButton();
  27. $grid->filter(function (Grid\Filter $filter) {
  28. $filter->panel();
  29. $filter->like('name')->width(4);
  30. });
  31. });
  32. }
  33. /**
  34. * Make a show builder.
  35. *
  36. * @param mixed $id
  37. *
  38. * @return Show
  39. */
  40. protected function detail($id)
  41. {
  42. return Show::make($id, new Student(), function (Show $show) {
  43. $show->field('id');
  44. $show->field('name');
  45. $show->field('sex');
  46. $show->field('month_old');
  47. $show->field('join_garden_time');
  48. $show->field('parent_name');
  49. $show->field('class_id');
  50. $show->field('name_en');
  51. $show->field('blood_type');
  52. $show->field('hypersensitive_source');
  53. $show->field('past_medical_history');
  54. $show->field('birthday');
  55. $show->field('exclusive_consultant_name');
  56. $show->field('exclusive_consultant_phone');
  57. $show->field('home_address');
  58. $show->field('hobby');
  59. $show->field('family_lang');
  60. $show->field('sleep_habits_and_others');
  61. $show->field('first_communication_of_parents');
  62. $show->field('created_at');
  63. $show->field('updated_at');
  64. });
  65. }
  66. /**
  67. * Make a form builder.
  68. *
  69. * @return Form
  70. */
  71. protected function form()
  72. {
  73. return Form::make(new Student(), function (Form $form) {
  74. //$form->display('id');
  75. $form->row(function (Form\Row $row) {
  76. $row->width(6)->text('name')->required()->placeholder('请输入中文名');
  77. $row->width(6)->text('name_en')->placeholder('请输入英文名');
  78. });
  79. $form->row(function (Form\Row $row) {
  80. $row->width(6)->select('sex')->options(config('map.sex'));
  81. $row->width(6)->select('blood_type')->options(config('map.blood_type'));
  82. });
  83. $form->row(function (Form\Row $row) {
  84. $row->width(12)->text('hypersensitive_source');
  85. });
  86. $form->row(function (Form\Row $row) {
  87. $row->textarea('past_medical_history')->required();
  88. });
  89. $form->row(function (Form\Row $row) {
  90. $row->width(6)->text('birthday')->required();
  91. $row->width(6)->text('join_garden_time');
  92. });
  93. $form->row(function (Form\Row $row) {
  94. $row->width(6)->text('exclusive_consultant_name')->placeholder('请输入专属顾问名');
  95. $row->width(6)->text('exclusive_consultant_phone')->placeholder('请输入专属顾问联系方式');
  96. });
  97. $form->row(function (Form\Row $row) {
  98. $row->width(6)->text('parent_name')->placeholder('请输入家长名');
  99. });
  100. $form->row(function (Form\Row $row) {
  101. $row->text('home_address');
  102. });
  103. $form->row(function (Form\Row $row) {
  104. $row->width(6)->text('hobby')->placeholder('请输入喜好');
  105. $row->width(6)->text('family_lang')->placeholder('请输入家庭语言');
  106. });
  107. $form->row(function (Form\Row $row) {
  108. $row->text('sleep_habits_and_others');
  109. });
  110. $form->row(function (Form\Row $row) {
  111. $row->textarea('first_communication_of_parents');
  112. });
  113. // $form->text('month_old');
  114. // $form->text('class_id');
  115. });
  116. }
  117. }