<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Auth\AdminPermission; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use ModStart\Core\Util\CRUDUtil; use ModStart\Grid\Displayer\ItemOperate; use ModStart\Grid\GridFilter; use ModStart\Repository\Filter\RepositoryFilter; use ModStart\Support\Concern\HasFields; use ModStart\Widget\TextAjaxRequest; use Module\Res\Event\ResAssetDeleted; class ResAssetRecycleController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $lZifj) { $lZifj->init('res_asset')->field(function ($lZifj) { $lZifj->id('id', 'ID'); $lZifj->select('categoryId', '分类')->optionModelTree('res_category'); $lZifj->text('title', '标题'); $lZifj->tags('tags', '标签')->serializeAsColonSeparated()->editable(false); $lZifj->display('created_at', L('Created At')); $lZifj->display('updated_at', L('Updated At')); })->repositoryFilter(function (RepositoryFilter $bu01d) { $bu01d->where('isDeleted', true); })->gridFilter(function (GridFilter $bu01d) { $bu01d->eq('id', L('ID')); $bu01d->like('title', L('Title')); $bu01d->has('categoryId', '分类')->cascaderModel('res_category'); })->hookItemOperateRendering(function (ItemOperate $zCZzC) { $jIWZA = $zCZzC->item(); $zCZzC->prepend(TextAjaxRequest::warning('恢复', modstart_admin_url('res_asset_recycle/restore', array('_id' => $jIWZA->id)), '确认恢复？')); })->canShow(false)->canAdd(false)->canEdit(false)->canBatchDelete(true)->title('资源回收站'); } public function delete() { goto qz3x2; u72XC: ModelUtil::decodeRecordsJson($f872E, array('pagePreviews')); goto BFchT; A1hkW: $f872E = ModelUtil::allIn('res_asset', 'id', $CQYv7); goto u72XC; mpN5x: $CQYv7 = CRUDUtil::ids(); goto A1hkW; j72mT: return Response::redirect(CRUDUtil::jsGridRefresh()); goto ztlBw; BFchT: foreach ($f872E as $zk4Tz) { goto FxABB; e1wQ9: ResAssetDeleted::fire($zk4Tz['id'], $zk4Tz); goto M78OV; FxABB: ModelUtil::delete('res_asset_access', array('assetId' => $zk4Tz['id'])); goto sFuk6; sFuk6: ModelUtil::delete('res_asset', $zk4Tz['id']); goto e1wQ9; M78OV: } goto j72mT; qz3x2: AdminPermission::demoCheck(); goto mpN5x; ztlBw: } public function restore() { goto tuSJP; mwG3r: return Response::redirect(CRUDUtil::jsGridRefresh()); goto Ei8S2; tuSJP: AdminPermission::demoCheck(); goto FYn4K; XXuS3: $sX2oK = ModelUtil::allIn('res_asset', 'id', $CQYv7); goto AP1x4; AP1x4: foreach ($sX2oK as $lpVAI) { ModelUtil::update('res_asset', $lpVAI['id'], array('isDeleted' => false)); } goto mwG3r; FYn4K: $CQYv7 = CRUDUtil::ids(); goto XXuS3; Ei8S2: } }