| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\Student;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use App\Admin\Controllers\AdminController;
- use Dcat\Admin\Layout\Content;
- use App\Models\ToothLog;
- class ToothLogController extends AdminController
- {
- public function index($parent, Content $content)
- {
- $title = '长牙记录';
- return $content
- ->title($title)
- ->description('列表')
- // 添加面包屑导航
- ->breadcrumb([
- 'text' => '返回列表',
- 'url' => admin_url('/student'),
- 'icon' => 'fa fa-step-backward'
- ],['text' => $title]
- )
- ->body($this->grid($parent));
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid($id)
- {
- return Grid::make(new ToothLog(), function (Grid $grid) use($id) {
- //$grid->column('student_id');
- $grid->column('student_id','学生信息')->display(function () {
- $str = "";
- $str .= "<div style='margin-right:10px;display: flex;align-items: center'>";
- $str .= '<img data-action="preview-img" src="' . $this->avatar . '" style="height:50px;width:50px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
- $str .= '<div>';
- $str .= '<p style="margin-bottom: 5px">' . $this->username . '</p>';
- $str .= '<p style="margin-bottom: 0px">' . $this->mobile . '</p>';
- $str .= "</div>";
- $str .= "</div>";
- return $str;
- });
- $grid->column('log_time');
- $grid->column('desc')->limit(50);
- $grid->column('photos')->display(function ($photo_urls){
- return json_decode($photo_urls, true);
- })->image('', '60', '60');;
- $grid->disableActions();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->panel();
- $filter->like('student_id')->width(4);
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new ToothLog(), function (Show $show) {
- $show->field('id');
-
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form($id)
- {
- return Form::make(new ToothLog(), function (Form $form) use($id) {
- $form->width(6)->datetime('time')->required()->placeholder('时间');
- $form->width(6)->textarea('desc')->placeholder('长牙描述');
- $form->width(6)->multipleImage('photos')->placeholder('上传照片')->saveAsJson();
- });
- }
- }
|