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