<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Article\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Field\AbstractField; use ModStart\Field\Type\FieldRenderMode; use ModStart\Form\Form; use ModStart\Grid\GridFilter; use ModStart\Support\Concern\HasFields; use ModStart\Widget\TextLink; use Module\Article\Type\ArticlePosition; use Module\Article\Util\ArticleUtil; class ArticleController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $A2Tuf) { $A2Tuf->init('article')->field(function ($A2Tuf) { $A2Tuf->id('id', 'ID'); $A2Tuf->select('position', '位置')->optionType(ArticlePosition::class); $A2Tuf->text('title', '名称')->hookRendering(function (AbstractField $iuKOG, $vPOhn, $x0NZ_) { switch ($iuKOG->renderMode()) { case FieldRenderMode::GRID: case FieldRenderMode::DETAIL: return TextLink::primary(htmlspecialchars($vPOhn->title), ArticleUtil::url($vPOhn->toArray()), 'target="_blank"'); } }); $A2Tuf->text('alias', '别名')->help('默认留空，可通过链接 /article/别名 访问'); $A2Tuf->richHtml('content', '内容')->listable(false); $A2Tuf->display('created_at', L('Created At'))->listable(false); $A2Tuf->display('updated_at', L('Updated At'))->listable(false); })->gridFilter(function (GridFilter $cbHm3) { $cbHm3->eq('position', '位置')->select(ArticlePosition::class); $cbHm3->like('title', L('Title')); })->title('通用文章')->hookSaved(function (Form $OkcU0) { ArticleUtil::clearCache(); }); } }