<?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 $IuwRA) { $IuwRA->init('banner')->field(function ($IuwRA) { $IuwRA->id('id', 'ID'); $IuwRA->select('position', '位置')->optionType(BannerPositionRemark::class); $IuwRA->image('image', '图片'); $IuwRA->radio('type', '样式类型')->optionType(BannerType::class)->when(BannerType::IMAGE_TITLE_SLOGAN_LINK, function ($tQByU) { $tQByU->text('title', '标题'); $tQByU->textarea('slogan', '内容描述'); $tQByU->text('linkText', '链接文字'); $tQByU->switch('colorReverse', '颜色反转'); })->when(BannerType::VIDEO, function ($tQByU) { $tQByU->video('video', '视频'); })->required(); $IuwRA->color('backgroundColor', '背景色'); $IuwRA->link('link', '链接'); $IuwRA->display('created_at', L('Created At'))->listable(false); $IuwRA->display('updated_at', L('Updated At'))->listable(false); })->gridFilter(function (GridFilter $wPpmz) { $wPpmz->eq('position', '位置')->select(BannerPosition::class); })->hookChanged(function (Form $s4jIj) { BannerUtil::clearCache(); })->canBatchDelete(true)->enablePagination(false)->defaultOrder(array('sort', 'asc'))->canSort(true)->title('轮播图片'); } }