ToothLogController.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 App\Admin\Controllers\AdminController;
  8. use Dcat\Admin\Layout\Content;
  9. use App\Models\ToothLog;
  10. class ToothLogController extends AdminController
  11. {
  12. public function index($parent, Content $content)
  13. {
  14. $title = '长牙记录';
  15. return $content
  16. ->title($title)
  17. ->description('列表')
  18. // 添加面包屑导航
  19. ->breadcrumb([
  20. 'text' => '返回列表',
  21. 'url' => admin_url('/student'),
  22. 'icon' => 'fa fa-step-backward'
  23. ],['text' => $title]
  24. )
  25. ->body($this->grid($parent));
  26. }
  27. /**
  28. * Make a grid builder.
  29. *
  30. * @return Grid
  31. */
  32. protected function grid($id)
  33. {
  34. return Grid::make(new ToothLog(), function (Grid $grid) use($id) {
  35. //$grid->column('student_id');
  36. $grid->column('student_id','学生信息')->display(function () {
  37. $str = "";
  38. $str .= "<div style='margin-right:10px;display: flex;align-items: center;padding-right:10px;'>";
  39. $str .= '<img data-action="preview-img" src="' . $this->student_id . '" style="height:56px;width:56px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
  40. $str .= '<div>';
  41. $str .= '<p style="margin:0px">姓名:小朋友</p>';
  42. $str .= '<p style="margin:0px">出生年月:2023-01-01</p>';
  43. $str .= '<p style="margin:0px">家庭住址:四川省成都市金牛区三泰魔方</p>';
  44. $str .= '<p style="margin:0px">所属班级:黄桃班</p>';
  45. $str .= '<p style="margin:0px">入园日期:2022-03-10</p>';
  46. $str .= "</div>";
  47. $str .= "</div>";
  48. return $str;
  49. });
  50. $grid->column('log_time');
  51. $grid->column('desc')->limit(50);
  52. $grid->column('photos')->display(function ($photo_urls){
  53. return json_decode($photo_urls, true);
  54. })->image('', '60', '60');;
  55. $grid->disableActions();
  56. $grid->filter(function (Grid\Filter $filter) {
  57. $filter->panel();
  58. $filter->like('student_id')->width(4);
  59. });
  60. });
  61. }
  62. /**
  63. * Make a show builder.
  64. *
  65. * @param mixed $id
  66. *
  67. * @return Show
  68. */
  69. protected function detail($id)
  70. {
  71. return Show::make($id, new ToothLog(), function (Show $show) {
  72. $show->field('id');
  73. });
  74. }
  75. /**
  76. * Make a form builder.
  77. *
  78. * @return Form
  79. */
  80. protected function form($id)
  81. {
  82. return Form::make(new ToothLog(), function (Form $form) use($id) {
  83. $form->width(6)->datetime('time')->required()->placeholder('时间');
  84. $form->width(6)->textarea('desc')->placeholder('长牙描述');
  85. $form->width(6)->multipleImage('photos')->placeholder('上传照片')->saveAsJson();
  86. });
  87. }
  88. }