<?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($w7Oqz, \Closure $J2v0t = null) { goto pY9gX; YwEF4: $this->repository = Repository::instance($w7Oqz); goto fPZbZ; dh_Gw: $this->builder($J2v0t); goto DLq7S; fPZbZ: $this->setupFields(); goto Lib4a; Lib4a: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto OAklM; pY9gX: $this->id = IdUtil::generate('Grid'); goto YwEF4; OAklM: $this->setupRepositoryFilter(); goto dh_Gw; DLq7S: } public static function make($vn_cr, \Closure $J2v0t = null) { if (is_object($vn_cr) || class_exists($vn_cr) && is_subclass_of($vn_cr, Model::class)) { return new Detail($vn_cr, $J2v0t); } return new Detail(DynamicModel::make($vn_cr), $J2v0t); } public function asTree($eAE99 = 'id', $aoubX = 'pid', $JK1jY = 'sort', $MpH1l = 'title') { goto jbbwt; NKtw6: $this->repository->setTreePidColumn($aoubX); goto utzil; NVq8u: $this->repository->setTreeTitleColumn($MpH1l); goto eRPHt; OnDDS: return $this; goto DoVrW; utzil: $this->repository->setSortColumn($JK1jY); goto NVq8u; eRPHt: $this->engine = DetailEngine::TREE; goto OnDDS; jbbwt: $this->repository->setKeyName($eAE99); goto NKtw6; DoVrW: } public function asTreeMass($mTunF = 0, $eAE99 = 'id', $aoubX = 'pid', $JK1jY = 'sort', $MpH1l = 'title') { goto iyHSZ; CIUV5: $this->repository->setTreePidColumn($aoubX); goto coKSm; brmxj: return $this; goto OemgV; ZiIfu: $this->repository->setTreeTitleColumn($MpH1l); goto zNiQj; coKSm: $this->repository->setSortColumn($JK1jY); goto ZiIfu; iyHSZ: $this->repository->setKeyName($eAE99); goto CIUV5; zNiQj: $this->engine = DetailEngine::TREE_MASS; goto brmxj; OemgV: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($yU7nJ) { goto oWKYB; VhRi6: $this->fillFields(); goto yTT1D; oWKYB: $this->itemId($yU7nJ); goto ijASm; ijASm: $this->item($this->repository()->show($this)); goto tALla; yTT1D: return $this; goto dL_1K; TFOHN: $this->build(); goto VhRi6; tALla: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto TFOHN; dL_1K: } public function render() { goto YRHZn; YRHZn: $zvN10 = array(); goto Vx0Ui; G_Udr: return view($this->view, $zvN10)->render(); goto Ty39o; Vx0Ui: $zvN10['fields'] = $this->showableFields(); goto vHHEW; vHHEW: $zvN10 = array_merge($this->fluentAttributeVariables(), $zvN10); goto G_Udr; Ty39o: } public function __call($pK00s, $rxS2C) { goto rSv8T; rSv8T: switch ($pK00s) { 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 Pre0m; DJtaQ: return FieldManager::call($this, $pK00s, $rxS2C); goto PXlR2; Pre0m: if ($this->isFluentAttribute($pK00s)) { return $this->fluentAttribute($pK00s, $rxS2C); } goto DJtaQ; PXlR2: } public function __toString() { try { return $this->render(); } catch (\Exception $Xlb8r) { return $Xlb8r->getMessage(); } } }