<?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($Qdgwn, \Closure $uZTwi = null) { goto gFpYd; arIIy: $this->setupRepositoryFilter(); goto s1w8d; gFpYd: $this->id = IdUtil::generate('Grid'); goto BqbQ5; KRahk: $this->setupFields(); goto KVkFq; BqbQ5: $this->repository = Repository::instance($Qdgwn); goto KRahk; s1w8d: $this->builder($uZTwi); goto KspSP; KVkFq: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto arIIy; KspSP: } public static function make($nzuw7, \Closure $uZTwi = null) { if (is_object($nzuw7) || class_exists($nzuw7) && is_subclass_of($nzuw7, Model::class)) { return new Detail($nzuw7, $uZTwi); } return new Detail(DynamicModel::make($nzuw7), $uZTwi); } public function asTree($MQulf = 'id', $dEd_G = 'pid', $afGtx = 'sort', $q6Qcb = 'title') { goto ti0wZ; jKeUR: return $this; goto ZLlG6; ti0wZ: $this->repository->setKeyName($MQulf); goto piO4d; j8EuD: $this->engine = DetailEngine::TREE; goto jKeUR; piO4d: $this->repository->setTreePidColumn($dEd_G); goto bnfEi; bnfEi: $this->repository->setSortColumn($afGtx); goto rVpw2; rVpw2: $this->repository->setTreeTitleColumn($q6Qcb); goto j8EuD; ZLlG6: } public function asTreeMass($UqpHl = 0, $MQulf = 'id', $dEd_G = 'pid', $afGtx = 'sort', $q6Qcb = 'title') { goto sZyQ4; G2pgs: $this->engine = DetailEngine::TREE_MASS; goto xZ8vZ; sZyQ4: $this->repository->setKeyName($MQulf); goto lvd1e; xZ8vZ: return $this; goto qejCX; qm_tU: $this->repository->setTreeTitleColumn($q6Qcb); goto G2pgs; lvd1e: $this->repository->setTreePidColumn($dEd_G); goto I01C7; I01C7: $this->repository->setSortColumn($afGtx); goto qm_tU; qejCX: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($jkTHm) { goto x3F7o; u1A8n: $this->item($this->repository()->show($this)); goto sEBR9; x3F7o: $this->itemId($jkTHm); goto u1A8n; sEBR9: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto Vgizp; Vgizp: $this->build(); goto kpUOj; jJGlu: return $this; goto dYXHh; kpUOj: $this->fillFields(); goto jJGlu; dYXHh: } public function render() { goto jRywA; dHGLz: $IaeCl['fields'] = $this->showableFields(); goto Ns5M_; Ns5M_: $IaeCl = array_merge($this->fluentAttributeVariables(), $IaeCl); goto TvLSG; jRywA: $IaeCl = array(); goto dHGLz; TvLSG: return view($this->view, $IaeCl)->render(); goto jJm5F; jJm5F: } public function __call($eNE35, $lUGZC) { goto tqs5x; yznXl: if ($this->isFluentAttribute($eNE35)) { return $this->fluentAttribute($eNE35, $lUGZC); } goto Wk1Cq; Wk1Cq: return FieldManager::call($this, $eNE35, $lUGZC); goto iFxf1; tqs5x: switch ($eNE35) { 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 yznXl; iFxf1: } public function __toString() { try { return $this->render(); } catch (\Exception $GrUf4) { return $GrUf4->getMessage(); } } }