StudentController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. use App\Admin\Actions\Form\ToothLog;
  9. class StudentController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new Student(), function (Grid $grid) {
  19. //$grid->column('id')->sortable();
  20. $grid->column('name');
  21. $grid->column('sex')->using(config('map.sex'));
  22. $grid->column('month_old');
  23. $grid->column('join_garden_time');
  24. $grid->column('parent_name');
  25. $grid->column('class_id')->using(config('map.class'));
  26. $grid->disableCreateButton();
  27. $grid->actions(function (Grid\Displayers\Actions $actions){
  28. //$actions->append(new Send(Order::class,$actions->row->id));
  29. $actions->append('成长数据');
  30. $actions->append('疫苗接种记录');
  31. $actions->append('考勤登记');
  32. $actions->append('相册');
  33. //$actions->append(new ToothLog(Student::class,$actions->row->id));
  34. $actions->append('<a href="' . admin_url('toothlog/' . $actions->row->id.'/index') . '">长牙记录</i></a>');
  35. });
  36. $grid->filter(function (Grid\Filter $filter) {
  37. $filter->panel();
  38. $filter->like('name')->width(4);
  39. });
  40. });
  41. }
  42. /**
  43. * Make a show builder.
  44. *
  45. * @param mixed $id
  46. *
  47. * @return Show
  48. */
  49. protected function detail($id)
  50. {
  51. return Show::make($id, new Student(), function (Show $show) {
  52. $show->field('id');
  53. $show->field('name');
  54. $show->field('sex');
  55. $show->field('month_old');
  56. $show->field('join_garden_time');
  57. $show->field('parent_name');
  58. $show->field('class_id');
  59. $show->field('name_en');
  60. $show->field('blood_type');
  61. $show->field('hypersensitive_source');
  62. $show->field('past_medical_history');
  63. $show->field('birthday');
  64. $show->field('exclusive_consultant_name');
  65. $show->field('exclusive_consultant_phone');
  66. $show->field('home_address');
  67. $show->field('hobby');
  68. $show->field('family_lang');
  69. $show->field('sleep_habits_and_others');
  70. $show->field('first_communication_of_parents');
  71. $show->field('created_at');
  72. $show->field('updated_at');
  73. });
  74. }
  75. /**
  76. * Make a form builder.
  77. *
  78. * @return Form
  79. */
  80. protected function form()
  81. {
  82. return Form::make(new Student(), function (Form $form) {
  83. //$form->display('id');
  84. $form->row(function (Form\Row $row) {
  85. $row->width(6)->text('name')->required()->placeholder('请输入中文名');
  86. $row->width(6)->text('name_en')->placeholder('请输入英文名');
  87. });
  88. $form->row(function (Form\Row $row) {
  89. $row->width(6)->select('sex')->options(config('map.sex'));
  90. $row->width(6)->select('blood_type')->options(config('map.blood_type'));
  91. });
  92. $form->row(function (Form\Row $row) {
  93. $row->width(12)->text('hypersensitive_source');
  94. });
  95. $form->row(function (Form\Row $row) {
  96. $row->textarea('past_medical_history')->required();
  97. });
  98. $form->row(function (Form\Row $row) {
  99. $row->width(6)->text('birthday')->required();
  100. $row->width(6)->text('join_garden_time');
  101. });
  102. $form->row(function (Form\Row $row) {
  103. $row->width(6)->text('exclusive_consultant_name')->placeholder('请输入专属顾问名');
  104. $row->width(6)->text('exclusive_consultant_phone')->placeholder('请输入专属顾问联系方式');
  105. });
  106. $form->row(function (Form\Row $row) {
  107. $row->width(6)->text('parent_name')->placeholder('请输入家长名');
  108. });
  109. $form->row(function (Form\Row $row) {
  110. $row->text('home_address');
  111. });
  112. $form->row(function (Form\Row $row) {
  113. $row->width(6)->text('hobby')->placeholder('请输入喜好');
  114. $row->width(6)->text('family_lang')->placeholder('请输入家庭语言');
  115. });
  116. $form->row(function (Form\Row $row) {
  117. $row->text('sleep_habits_and_others');
  118. });
  119. $form->row(function (Form\Row $row) {
  120. $row->textarea('first_communication_of_parents');
  121. });
  122. // $form->text('month_old');
  123. // $form->text('class_id');
  124. });
  125. }
  126. }