<?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($kEh5R, \Closure $Aw5eZ = null) { goto ewXUI; ewt2M: $this->setupFields(); goto JH9_0; XRxTS: $this->repository = Repository::instance($kEh5R); goto ewt2M; PFpPG: $this->builder($Aw5eZ); goto rLmYT; i5GY3: $this->setupRepositoryFilter(); goto PFpPG; JH9_0: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto i5GY3; ewXUI: $this->id = IdUtil::generate('Grid'); goto XRxTS; rLmYT: } public static function make($DRh9Q, \Closure $Aw5eZ = null) { if (is_object($DRh9Q) || class_exists($DRh9Q) && is_subclass_of($DRh9Q, Model::class)) { return new Detail($DRh9Q, $Aw5eZ); } return new Detail(DynamicModel::make($DRh9Q), $Aw5eZ); } public function asTree($CnFib = 'id', $YyOZV = 'pid', $ydNx4 = 'sort', $e03hh = 'title') { goto T9Vzw; XlyAc: return $this; goto WoZKj; raAAq: $this->engine = DetailEngine::TREE; goto XlyAc; py6au: $this->repository->setTreeTitleColumn($e03hh); goto raAAq; ud_NR: $this->repository->setTreePidColumn($YyOZV); goto GHnqB; T9Vzw: $this->repository->setKeyName($CnFib); goto ud_NR; GHnqB: $this->repository->setSortColumn($ydNx4); goto py6au; WoZKj: } public function asTreeMass($gNhjm = 0, $CnFib = 'id', $YyOZV = 'pid', $ydNx4 = 'sort', $e03hh = 'title') { goto E5jae; efILR: $this->engine = DetailEngine::TREE_MASS; goto uDLrF; E5jae: $this->repository->setKeyName($CnFib); goto BFPjC; tIgOj: $this->repository->setSortColumn($ydNx4); goto mzLx8; mzLx8: $this->repository->setTreeTitleColumn($e03hh); goto efILR; BFPjC: $this->repository->setTreePidColumn($YyOZV); goto tIgOj; uDLrF: return $this; goto FAEVL; FAEVL: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($PMDE9) { goto MKWw0; rhRUk: $this->build(); goto i9O3f; MKWw0: $this->itemId($PMDE9); goto hRpxr; hRpxr: $this->item($this->repository()->show($this)); goto VbNEo; YX_l0: return $this; goto gencP; VbNEo: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto rhRUk; i9O3f: $this->fillFields(); goto YX_l0; gencP: } public function render() { goto oBZ7k; QHmkC: $Sj05q = array_merge($this->fluentAttributeVariables(), $Sj05q); goto N7FV_; oBZ7k: $Sj05q = array(); goto bZcMW; N7FV_: return view($this->view, $Sj05q)->render(); goto iS0gj; bZcMW: $Sj05q['fields'] = $this->showableFields(); goto QHmkC; iS0gj: } public function __call($hiFdg, $lLyBI) { goto vJX3R; XLFvV: if ($this->isFluentAttribute($hiFdg)) { return $this->fluentAttribute($hiFdg, $lLyBI); } goto MUsK1; vJX3R: switch ($hiFdg) { 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 XLFvV; MUsK1: return FieldManager::call($this, $hiFdg, $lLyBI); goto dA_Ee; dA_Ee: } public function __toString() { try { return $this->render(); } catch (\Exception $tZVhb) { return $tZVhb->getMessage(); } } }