StudentController.php 4.9 KB

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