<?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($UgPp_, \Closure $RHogU = null) { goto d15Bg; d15Bg: $this->id = IdUtil::generate('Grid'); goto dh6IK; zgmz7: $this->setupRepositoryFilter(); goto FlTdc; dh6IK: $this->repository = Repository::instance($UgPp_); goto yUMVq; FlTdc: $this->builder($RHogU); goto Ffliu; s5CnZ: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto zgmz7; yUMVq: $this->setupFields(); goto s5CnZ; Ffliu: } public static function make($GMqtO, \Closure $RHogU = null) { if (is_object($GMqtO) || class_exists($GMqtO) && is_subclass_of($GMqtO, Model::class)) { return new Detail($GMqtO, $RHogU); } return new Detail(DynamicModel::make($GMqtO), $RHogU); } public function asTree($WoS8y = 'id', $tmOos = 'pid', $VndCZ = 'sort', $b3mXO = 'title') { goto X8t6M; X8t6M: $this->repository->setKeyName($WoS8y); goto SuFUE; vs7qM: $this->engine = DetailEngine::TREE; goto lwj2_; lwj2_: return $this; goto f8qFb; wVKxg: $this->repository->setSortColumn($VndCZ); goto J8lg1; SuFUE: $this->repository->setTreePidColumn($tmOos); goto wVKxg; J8lg1: $this->repository->setTreeTitleColumn($b3mXO); goto vs7qM; f8qFb: } public function asTreeMass($sIdKA = 0, $WoS8y = 'id', $tmOos = 'pid', $VndCZ = 'sort', $b3mXO = 'title') { goto e3wc9; eYOw3: $this->repository->setTreeTitleColumn($b3mXO); goto ROWU5; OoZdl: return $this; goto fBFSe; ROWU5: $this->engine = DetailEngine::TREE_MASS; goto OoZdl; e3wc9: $this->repository->setKeyName($WoS8y); goto n4Yhj; UY_aV: $this->repository->setSortColumn($VndCZ); goto eYOw3; n4Yhj: $this->repository->setTreePidColumn($tmOos); goto UY_aV; fBFSe: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($Zzend) { goto MwU3t; g1GNd: return $this; goto yuoI0; MwU3t: $this->itemId($Zzend); goto eAkpZ; eAkpZ: $this->item($this->repository()->show($this)); goto o4Sb5; jVnpL: $this->fillFields(); goto g1GNd; o4Sb5: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto BO1UM; BO1UM: $this->build(); goto jVnpL; yuoI0: } public function render() { goto tvMYv; u1sQ9: return view($this->view, $dTnlu)->render(); goto tG2qR; P9EGR: $dTnlu['fields'] = $this->showableFields(); goto wbAyx; wbAyx: $dTnlu = array_merge($this->fluentAttributeVariables(), $dTnlu); goto u1sQ9; tvMYv: $dTnlu = array(); goto P9EGR; tG2qR: } public function __call($UVOMF, $bY7Wp) { goto ZK00x; ZK00x: switch ($UVOMF) { 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': case 'useSimple': case 'gridRowCols': return $this; } goto r6yyA; f325i: return FieldManager::call($this, $UVOMF, $bY7Wp); goto s2TZx; r6yyA: if ($this->isFluentAttribute($UVOMF)) { return $this->fluentAttribute($UVOMF, $bY7Wp); } goto f325i; s2TZx: } public function __toString() { try { return $this->render(); } catch (\Exception $Sgh1N) { return $Sgh1N->getMessage(); } } }