123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\WxNavigation;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxNavigationController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxNavigation('plate'), function (Grid $grid) {
- $grid->column('id')->sortable();
- $grid->column('sort')->editable();
- $grid->column('plate.name', '所属板块');
- $grid->column('icon')->image('', 50);
- $grid->column('link');
- $grid->column('name');
- $grid->column('introduce');
- $grid->column('type')->using([0 => '资源素材', 1 => '工具利器'])->label([
- 0 => 'primary',
- 1 => 'blue',
- ]);
- $grid->column('state')->using([0 => '正常', 1 => '下架'])->label([
- 0 => 'primary',
- 1 => 'red',
- ]);
- $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 WxNavigation(), function (Show $show) {
- $show->field('id');
- $show->field('np_id');
- $show->field('icon');
- $show->field('link');
- $show->field('name');
- $show->field('introduce');
- $show->field('sort');
- $show->field('type');
- $show->field('state');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxNavigation(), function (Form $form) {
- $form->display('id');
- $form->text('np_id');
- $form->image('icon')->url('files/uploads')->uniqueName();
- $form->text('link');
- $form->text('name');
- $form->text('introduce');
- $form->text('sort');
- $form->text('type');
- $form->text('state');
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|