<?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($kZXWm, \Closure $p40Fy = null) { goto VoD2U; VoD2U: $this->id = IdUtil::generate('Grid'); goto DfygO; OVAIO: $this->setupRepositoryFilter(); goto D9cfK; bKquG: $this->setupFields(); goto DvmYR; DvmYR: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto OVAIO; DfygO: $this->repository = Repository::instance($kZXWm); goto bKquG; D9cfK: $this->builder($p40Fy); goto K1Wl_; K1Wl_: } public static function make($xTADA, \Closure $p40Fy = null) { if (is_object($xTADA) || class_exists($xTADA) && is_subclass_of($xTADA, Model::class)) { return new Detail($xTADA, $p40Fy); } return new Detail(DynamicModel::make($xTADA), $p40Fy); } public function asTree($lwKEo = 'id', $ggQwu = 'pid', $T9Z9v = 'sort', $uNsqC = 'title') { goto liaDj; CIWH_: $this->repository->setTreePidColumn($ggQwu); goto eaJfV; wuNw8: $this->repository->setTreeTitleColumn($uNsqC); goto R4OMk; eaJfV: $this->repository->setSortColumn($T9Z9v); goto wuNw8; liaDj: $this->repository->setKeyName($lwKEo); goto CIWH_; R4OMk: $this->engine = DetailEngine::TREE; goto qryEY; qryEY: return $this; goto Xix1H; Xix1H: } public function asTreeMass($m7eoQ = 0, $lwKEo = 'id', $ggQwu = 'pid', $T9Z9v = 'sort', $uNsqC = 'title') { goto xtD_k; IAIZo: $this->repository->setTreePidColumn($ggQwu); goto fTHMM; N_ndc: $this->engine = DetailEngine::TREE_MASS; goto J_INR; fTHMM: $this->repository->setSortColumn($T9Z9v); goto zLXOm; xtD_k: $this->repository->setKeyName($lwKEo); goto IAIZo; J_INR: return $this; goto sNTPW; zLXOm: $this->repository->setTreeTitleColumn($uNsqC); goto N_ndc; sNTPW: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($D_1N9) { goto sU6t4; sU6t4: $this->itemId($D_1N9); goto Q2RPH; Po_R4: $this->fillFields(); goto o9VYy; RYKD8: $this->build(); goto Po_R4; uR02V: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto RYKD8; Q2RPH: $this->item($this->repository()->show($this)); goto uR02V; o9VYy: return $this; goto huy1s; huy1s: } public function render() { goto I38xo; Q5pOy: return view($this->view, $zonFp)->render(); goto u47aa; I38xo: $zonFp = array(); goto sW7CS; khcHE: $zonFp = array_merge($this->fluentAttributeVariables(), $zonFp); goto Q5pOy; sW7CS: $zonFp['fields'] = $this->showableFields(); goto khcHE; u47aa: } public function __call($fVu6a, $RSGSj) { goto IeWzq; Ygf2X: return FieldManager::call($this, $fVu6a, $RSGSj); goto tuV7D; yCp18: if ($this->isFluentAttribute($fVu6a)) { return $this->fluentAttribute($fVu6a, $RSGSj); } goto Ygf2X; IeWzq: switch ($fVu6a) { 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 yCp18; tuV7D: } public function __toString() { try { return $this->render(); } catch (\Exception $SwVsw) { return $SwVsw->getMessage(); } } }