123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace App\Admin\Controllers;
- use App\Model\DeviceType;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class DeviceTypeController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '设备类型';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new DeviceType());
- $grid->disableCreateButton(false);
- $grid->column('id', __('编号'));
- $grid->column('name', __('名称'));
- $grid->column('number', __('箱体数量'));
- $grid->column('image', __('图片'))->display(function ($w){
- return '<img src="/upload/'.$w.'" style="width:50px;height:50px"/>';
- });
- $grid->column('created_at', __('创建时间'));
- $grid->column('updated_at', __('更新时间'));
- $grid->actions(function ($actions){
- $actions->disableView(false);
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(DeviceType::findOrFail($id));
- $show->field('id', __('编号'));
- $show->field('name', __('名称'));
- $show->field('number', __('箱体个数'));
- $show->field('remark', __('备注'));
- $show->field('image', __('图片'))->image();
- $show->field('created_at', __('创建时间'));
- $show->field('updated_at', __('更新时间'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new DeviceType());
- $form->text('name', __('名称'));
- $form->text('number', __('箱体个数'));
- $form->textarea('remark', __('备注'));
- $form->image('image', __('图片'));
- return $form;
- }
- }
|