<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Detail; use Illuminate\Contracts\Support\Renderable; use Illuminate\Database\Eloquent\Model; use ModStart\Core\Dao\DynamicModel; use ModStart\Core\Exception\BizException; use ModStart\Core\Util\IdUtil; use ModStart\Detail\Type\DetailEngine; use ModStart\Field\AbstractField; use ModStart\Field\Type\FieldRenderMode; use ModStart\Form\Concern\HasCascadeFields; use ModStart\Form\Form; use ModStart\Repository\Filter\HasRepositoryFilter; use ModStart\Repository\Filter\HasScopeFilter; use ModStart\Repository\Repository; use ModStart\Support\Concern\HasBuilder; use ModStart\Support\Concern\HasFields; use ModStart\Support\Concern\HasFluentAttribute; use ModStart\Support\Manager\FieldManager; class Detail implements Renderable { use HasFields, HasBuilder, HasFluentAttribute, HasCascadeFields, HasScopeFilter, HasRepositoryFilter; private $id; private $repository; private $view = 'modstart::core.detail.index'; private $fluentAttributes = array('engine', 'title', 'itemId', 'item', 'formClass'); private $engine = 'basic'; private $title; private $itemId = null; private $item; private $formClass = ''; public function __construct($WLLL5, \Closure $uKcQx = null) { goto QPQFp; xUttZ: $this->setupRepositoryFilter(); goto G59Ak; Xd45U: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto xUttZ; l3ff6: $this->setupFields(); goto Xd45U; QPQFp: $this->id = IdUtil::generate('Grid'); goto ORN30; G59Ak: $this->builder($uKcQx); goto ueQ_S; ORN30: $this->repository = Repository::instance($WLLL5); goto l3ff6; ueQ_S: } public static function make($uV19D, \Closure $uKcQx = null) { if (is_object($uV19D) || class_exists($uV19D) && is_subclass_of($uV19D, Model::class)) { return new Detail($uV19D, $uKcQx); } return new Detail(DynamicModel::make($uV19D), $uKcQx); } public function asTree($bZCgI = 'id', $JwI8J = 'pid', $L9SE2 = 'sort', $Tm4RB = 'title') { goto XhDoX; fcSZ2: $this->repository->setTreePidColumn($JwI8J); goto FHqBk; FHqBk: $this->repository->setSortColumn($L9SE2); goto NyT2v; XhDoX: $this->repository->setKeyName($bZCgI); goto fcSZ2; NyT2v: $this->repository->setTreeTitleColumn($Tm4RB); goto YFVGf; wt_Uv: return $this; goto XeKlO; YFVGf: $this->engine = DetailEngine::TREE; goto wt_Uv; XeKlO: } public function asTreeMass($VLnVJ = 0, $bZCgI = 'id', $JwI8J = 'pid', $L9SE2 = 'sort', $Tm4RB = 'title') { goto Z9gPX; usOUT: $this->repository->setSortColumn($L9SE2); goto UTXsG; uJwkP: $this->engine = DetailEngine::TREE_MASS; goto cm3eS; cm3eS: return $this; goto tMdiJ; UTXsG: $this->repository->setTreeTitleColumn($Tm4RB); goto uJwkP; Z9gPX: $this->repository->setKeyName($bZCgI); goto ffoVd; ffoVd: $this->repository->setTreePidColumn($JwI8J); goto usOUT; tMdiJ: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($xYu70) { goto hTW9x; f9EvX: $this->item($this->repository()->show($this)); goto xHuAF; SK40V: $this->fillFields(); goto jMuRt; hTW9x: $this->itemId($xYu70); goto f9EvX; nOv0W: $this->build(); goto SK40V; jMuRt: return $this; goto VBSbk; xHuAF: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto nOv0W; VBSbk: } public function render() { goto obfyh; kD0NE: return view($this->view, $OTBPk)->render(); goto EmhGA; obfyh: $OTBPk = array(); goto wx3RN; wx3RN: $OTBPk['fields'] = $this->showableFields(); goto St10A; St10A: $OTBPk = array_merge($this->fluentAttributeVariables(), $OTBPk); goto kD0NE; EmhGA: } public function __call($HxDDI, $CUZy6) { goto NbE7g; NbE7g: switch ($HxDDI) { case 'enablePagination': case 'defaultOrder': case 'canAdd': case 'canEdit': case 'canDelete': case 'canSort': case 'canShow': case 'canExport': case 'canImport': case 'canCopy': case 'canBatchDelete': case 'treeMaxLevel': case 'hookSaving': case 'hookSaved': case 'hookChanged': case 'hookDeleting': case 'hookDeleted': case 'hookItemOperateRendering': case 'addBlankPage': case 'editBlankPage': case 'disableCUD': case 'addDialogSize': case 'editDialogSize': case 'dialogSizeSmall': case 'gridFilter': case 'canMultiSelectItem': case 'gridOperateAppend': case 'bodyAppend': case 'operateFixed': case 'defaultPageSize': case 'pageSizes': case 'canBatchSelect': case 'batchOperatePrepend': case 'gridToolbar': case 'pageJumpEnable': case 'textEdit': case 'gridTableTopView': case 'gridBeforeRequestScriptView': case 'gridRequestScript': case 'sortAddPosition': case 'titleAdd': case 'titleEdit': return $this; } goto uwPVr; uwPVr: if ($this->isFluentAttribute($HxDDI)) { return $this->fluentAttribute($HxDDI, $CUZy6); } goto gV0LH; gV0LH: return FieldManager::call($this, $HxDDI, $CUZy6); goto LgyXl; LgyXl: } public function __toString() { try { return $this->render(); } catch (\Exception $Y5fnH) { return $Y5fnH->getMessage(); } } }