<?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($quOXO, \Closure $jKEZz = null) { goto dQZ3e; zBRTk: $this->repository = Repository::instance($quOXO); goto FQ1zR; upLKd: $this->builder($jKEZz); goto cCj10; dQZ3e: $this->id = IdUtil::generate('Grid'); goto zBRTk; FQ1zR: $this->setupFields(); goto qpbYH; Frh2J: $this->setupRepositoryFilter(); goto upLKd; qpbYH: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto Frh2J; cCj10: } public static function make($w5oww, \Closure $jKEZz = null) { if (is_object($w5oww) || class_exists($w5oww) && is_subclass_of($w5oww, Model::class)) { return new Detail($w5oww, $jKEZz); } return new Detail(DynamicModel::make($w5oww), $jKEZz); } public function asTree($aKi50 = 'id', $w0d_G = 'pid', $hV2ys = 'sort', $oHDs7 = 'title') { goto OhbdX; E2_o1: $this->engine = DetailEngine::TREE; goto LK2aX; OhbdX: $this->repository->setKeyName($aKi50); goto p5yWa; p5yWa: $this->repository->setTreePidColumn($w0d_G); goto Yefww; Yefww: $this->repository->setSortColumn($hV2ys); goto m5Sjg; LK2aX: return $this; goto F0bIG; m5Sjg: $this->repository->setTreeTitleColumn($oHDs7); goto E2_o1; F0bIG: } public function asTreeMass($YO89j = 0, $aKi50 = 'id', $w0d_G = 'pid', $hV2ys = 'sort', $oHDs7 = 'title') { goto OQwMQ; OQwMQ: $this->repository->setKeyName($aKi50); goto ePlX3; ePlX3: $this->repository->setTreePidColumn($w0d_G); goto mK4Dh; uRW0G: $this->engine = DetailEngine::TREE_MASS; goto JIE6O; mK4Dh: $this->repository->setSortColumn($hV2ys); goto Zk61_; Zk61_: $this->repository->setTreeTitleColumn($oHDs7); goto uRW0G; JIE6O: return $this; goto tHWFv; tHWFv: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($mK69g) { goto rXZOh; BCBVI: return $this; goto p7y2K; skECz: $this->item($this->repository()->show($this)); goto CucLy; C1N8c: $this->fillFields(); goto BCBVI; rXZOh: $this->itemId($mK69g); goto skECz; CucLy: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto ctm2W; ctm2W: $this->build(); goto C1N8c; p7y2K: } public function render() { goto bSjv5; HgSLO: $SjN8A['fields'] = $this->showableFields(); goto HaB0x; bSjv5: $SjN8A = array(); goto HgSLO; HaB0x: $SjN8A = array_merge($this->fluentAttributeVariables(), $SjN8A); goto FLHi8; FLHi8: return view($this->view, $SjN8A)->render(); goto wgMe1; wgMe1: } public function __call($HkVnj, $nvZ9A) { goto xPFRG; p34TB: if ($this->isFluentAttribute($HkVnj)) { return $this->fluentAttribute($HkVnj, $nvZ9A); } goto PD5Py; PD5Py: return FieldManager::call($this, $HkVnj, $nvZ9A); goto AqdHo; xPFRG: switch ($HkVnj) { 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 p34TB; AqdHo: } public function __toString() { try { return $this->render(); } catch (\Exception $xpJqz) { return $xpJqz->getMessage(); } } }