<?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($lZ6bd, \Closure $SYUtr = null) { goto d1VvB; zf2Zq: $this->setupFields(); goto fz2at; ffNmg: $this->setupRepositoryFilter(); goto t54wP; TAWok: $this->repository = Repository::instance($lZ6bd); goto zf2Zq; d1VvB: $this->id = IdUtil::generate('Grid'); goto TAWok; fz2at: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto ffNmg; t54wP: $this->builder($SYUtr); goto sAfTm; sAfTm: } public static function make($TAWWJ, \Closure $SYUtr = null) { if (is_object($TAWWJ) || class_exists($TAWWJ) && is_subclass_of($TAWWJ, \Illuminate\Database\Eloquent\Model::class)) { return new Detail($TAWWJ, $SYUtr); } return new Detail(DynamicModel::make($TAWWJ), $SYUtr); } public function asTree($ZL1Sk = 'id', $o4fL_ = 'pid', $wMb4e = 'sort', $aLw47 = 'title') { goto v4LVX; QR6os: $this->repository->setTreeTitleColumn($aLw47); goto f_t8k; v4LVX: $this->repository->setKeyName($ZL1Sk); goto yqn0l; yqn0l: $this->repository->setTreePidColumn($o4fL_); goto v70DO; a6ivw: return $this; goto T_WET; v70DO: $this->repository->setSortColumn($wMb4e); goto QR6os; f_t8k: $this->engine = DetailEngine::TREE; goto a6ivw; T_WET: } public function asTreeMass($vf3Na = 0, $ZL1Sk = 'id', $o4fL_ = 'pid', $wMb4e = 'sort', $aLw47 = 'title') { goto OufDH; Y1A6U: return $this; goto tvk3x; cMYIS: $this->repository->setTreeTitleColumn($aLw47); goto UGYdO; Chlo_: $this->repository->setTreePidColumn($o4fL_); goto Z6zZB; UGYdO: $this->engine = DetailEngine::TREE_MASS; goto Y1A6U; OufDH: $this->repository->setKeyName($ZL1Sk); goto Chlo_; Z6zZB: $this->repository->setSortColumn($wMb4e); goto cMYIS; tvk3x: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($sIQGl) { goto L2fwE; Hz_iD: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto xUtsG; wkUi3: return $this; goto gaGaW; xUtsG: $this->build(); goto a4ZDH; L2fwE: $this->itemId($sIQGl); goto TH7MT; TH7MT: $this->item($this->repository()->show($this)); goto Hz_iD; a4ZDH: $this->fillFields(); goto wkUi3; gaGaW: } public function render() { goto SUTf4; RFG_r: return view($this->view, $EdQjV)->render(); goto kjZNG; SUTf4: $EdQjV = array(); goto KVd6w; yXnuR: $EdQjV = array_merge($this->fluentAttributeVariables(), $EdQjV); goto RFG_r; KVd6w: $EdQjV['fields'] = $this->showableFields(); goto yXnuR; kjZNG: } public function __call($JHYOH, $HPXJC) { goto BGFye; UtE7y: if ($this->isFluentAttribute($JHYOH)) { return $this->fluentAttribute($JHYOH, $HPXJC); } goto e5RGB; e5RGB: return FieldManager::call($this, $JHYOH, $HPXJC); goto yIOGS; BGFye: switch ($JHYOH) { 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': return $this; } goto UtE7y; yIOGS: } }