<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Banner\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Form\Form; use ModStart\Grid\GridFilter; use ModStart\Support\Concern\HasFields; use Module\Banner\Type\BannerPosition; use Module\Banner\Type\BannerPositionRemark; use Module\Banner\Type\BannerType; use Module\Banner\Util\BannerUtil; class BannerController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $P2vse) { $P2vse->init('banner')->field(function ($P2vse) { $P2vse->id('id', 'ID'); $P2vse->select('position', '位置')->optionType(BannerPositionRemark::class); $P2vse->image('image', '图片'); $P2vse->radio('type', '样式类型')->optionType(BannerType::class)->when(BannerType::IMAGE_TITLE_SLOGAN_LINK, function ($TEzN5) { $TEzN5->text('title', '标题'); $TEzN5->textarea('slogan', '内容描述'); $TEzN5->text('linkText', '链接文字'); $TEzN5->switch('colorReverse', '颜色反转'); })->when(BannerType::VIDEO, function ($TEzN5) { $TEzN5->video('video', '视频'); })->required(); $P2vse->color('backgroundColor', '背景色'); $P2vse->link('link', '链接'); $P2vse->display('created_at', L('Created At'))->listable(false); $P2vse->display('updated_at', L('Updated At'))->listable(false); })->gridFilter(function (GridFilter $mHisM) { $mHisM->eq('position', '位置')->select(BannerPosition::class); })->hookChanged(function (Form $NX6uw) { BannerUtil::clearCache(); })->canBatchDelete(true)->enablePagination(false)->defaultOrder(array('sort', 'asc'))->canSort(true)->title('轮播图片'); } }