123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Admin\Controllers;
- use App\Wen\Utils\FieldUtils;
- use App\Wen\Utils\Utils;
- use App\Models\Posts\WxPost;
- use App\Models\Posts\WxTag;
- use App\Models\Circle\WxCircle;
- use App\Models\Shop\WxShopGoods;
- use App\Models\WxSlideshow;
- use App\Models\WxGift;
- use App\Models\User\WxUser;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxLiwuController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxGift(), function (Grid $grid) {
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
- }
- $grid->column('name');
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- $grid->column('photo_url')->image('',80);
- $grid->column('price');
-
- // $grid->column('slideshow_state')->switch();
- // $grid->column('created_at');
- //$grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- $grid->disableViewButton();
- //$grid->disableCreateButton();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new WxGift(), function (Show $show) {
- $show->field('id');
- $show->field('name');
- $show->field('price');
- $show->field('photo_url')->image('',80);
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxGift(), function (Form $form) {
- $form->display('id');
- $form->text('name', '名称');
- $form->text('price', '价格');
- $form->image('photo_url')->url('files/uploads')->autoUpload();
- $form->saving(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- $form->tenant_id = $__MINI_GLOBAL_TENANT_ID__;
- });
- $form->deleting(function (Form $form){
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- return $form->response()->error('权限不足,不可以删除其他分站对象');
- }
- });
-
- });
- }
- }
|