123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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\WxXiangqin;
- use App\Models\User\WxUser;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class WxXiangqinController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new WxXiangqin(), function (Grid $grid) {
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
- }
- $grid->model()->orderBy('id', 'desc');
- $grid->column('id')->sortable();
- // $grid->column('poster')->image('',80);
- // $grid->column('sort')->editable();
- $grid->column('type')->using(FieldUtils::getUrlTypesOne())->label([
- 'default' => 'primary', // 设置默认颜色,不设置则默认为 default
- ]);
- $grid->column('target_id', '跳转id');
- // $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 WxXiangqin(), function (Show $show) {
- $show->field('id');
- $show->field('poster');
- $show->field('target_id');
- $show->field('slideshow_type');
- $show->field('slideshow_state');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new WxXiangqin(), function (Form $form) {
- $form->display('id')->help('<a href="#" >路径大全</a>');;
- // $form->radio('slideshow_type')->options(FieldUtils::getUrlTypes())->default(0)->required();
- $form->text('target_id', '跳转id')->help('<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>');
- // $form->switch('slideshow_state');
- global $__MINI_GLOBAL_TENANT_ID__;
- if($__MINI_GLOBAL_TENANT_ID__ > 0){
- $form->text('tenant_id', '本站分应用id')->help('忽略这个配置')->default($__MINI_GLOBAL_TENANT_ID__);
- }
- $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('权限不足,不可以删除其他分站对象');
- }
- });
- });
- }
- }
|