123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace App\Admin\Controllers\Used;
- use App\Admin\Repositories\Used\WxUsedClassify;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxUsedClassifyController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxUsedClassify(), function (Grid $grid) {
- $grid->model()->orderBy('order', 'desc')->orderBy('id', 'desc');
- $grid->quickSearch(['id', 'name','desc'])->placeholder('搜索ID,名字,简介...')->width(50);
- $grid->column('id')->sortable();
- $grid->column('order')->editable()->sortable();
- $grid->column('name');
- $grid->column('desc');
- $grid->column('pic')->image('', 80, 80);
- $grid->column('bg_img')->image('', 80, 80);
- $grid->column('status')->switch();
- $grid->column('created_at')->sortable();
- // $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxUsedClassify(), function (Show $show) {
- $show->field('id');
- $show->field('order');
- $show->field('name');
- $show->field('desc');
- $show->field('pic');
- $show->field('bg_img');
- $show->field('status');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxUsedClassify(), function (Form $form) {
- $form->display('id');
- $form->number('order')->default(0);
- $form->text('name')->help('建议不超过4字')->required();
- $form->textarea('desc')->required();
- $form->image('pic')->url('files/uploads')->uniqueName()->autoUpload()->required();
- $form->image('bg_img')->url('files/uploads')->uniqueName()->autoUpload()->required();
- $form->switch('status')->default(1);
- $form->display('created_at');
- $form->display('updated_at');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|