<?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\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; private $id; private $repository; private $view = 'modstart::core.detail.index'; private $fluentAttributes = array('engine', 'title', 'itemId', 'item'); private $engine = 'basic'; private $title; private $itemId = null; private $item; public function __construct($a_UAg, \Closure $fb3zO = null) { goto nIXZ8; gID1x: $this->repository = Repository::instance($a_UAg); goto yOyy1; yOyy1: $this->setupFields(); goto YvQk2; nIXZ8: $this->id = IdUtil::generate('Grid'); goto gID1x; YvQk2: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto hLs4k; hLs4k: $this->builder($fb3zO); goto MBHsP; MBHsP: } public static function make($pWRTh, \Closure $fb3zO = null) { if (class_exists($pWRTh) && is_subclass_of($pWRTh, \Illuminate\Database\Eloquent\Model::class)) { return new Detail($pWRTh, $fb3zO); } return new Detail(DynamicModel::make($pWRTh), $fb3zO); } public function asTree($kkQsP = 'id', $b_wxs = 'pid', $uY1vf = 'sort', $ysr4x = 'title') { goto yZ6QS; QD4Dn: $this->repository->setTreeTitleColumn($ysr4x); goto N3Kfu; opswk: $this->repository->setTreePidColumn($b_wxs); goto isMCq; isMCq: $this->repository->setSortColumn($uY1vf); goto QD4Dn; yZ6QS: $this->repository->setKeyName($kkQsP); goto opswk; HPF9w: return $this; goto GzKin; N3Kfu: $this->engine = DetailEngine::TREE; goto HPF9w; GzKin: } public function asTreeMass($IV7Lu = 0, $kkQsP = 'id', $b_wxs = 'pid', $uY1vf = 'sort', $ysr4x = 'title') { goto c1tvO; cj6kr: $this->repository->setTreePidColumn($b_wxs); goto DYhDE; c1tvO: $this->repository->setKeyName($kkQsP); goto cj6kr; DYhDE: $this->repository->setSortColumn($uY1vf); goto GTz4V; XHe8I: $this->engine = DetailEngine::TREE_MASS; goto GUGqH; GTz4V: $this->repository->setTreeTitleColumn($ysr4x); goto XHe8I; GUGqH: return $this; goto AND6_; AND6_: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($UFOLC) { goto rSO1A; CPSrA: $this->fillFields(); goto ilxZw; NWQpZ: $this->build(); goto CPSrA; rSO1A: $this->itemId($UFOLC); goto EzIg2; uso78: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto NWQpZ; EzIg2: $this->item($this->repository()->show($this)); goto uso78; ilxZw: return $this; goto cJ2Hp; cJ2Hp: } public function render() { goto sw4o5; KBvLg: return view($this->view, $Y0YxF)->render(); goto uw2jm; sw4o5: $Y0YxF = array(); goto Vw0hc; DN9rO: $Y0YxF = array_merge($this->fluentAttributeVariables(), $Y0YxF); goto KBvLg; Vw0hc: $Y0YxF['fields'] = $this->showableFields(); goto DN9rO; uw2jm: } public function __call($WIVcd, $MVaFK) { goto UgFxT; UgFxT: switch ($WIVcd) { case 'enablePagination': case 'defaultOrder': case 'canAdd': case 'canEdit': case 'canDelete': case 'canSort': case 'canShow': case 'canBatchDelete': case 'treeMaxLevel': case 'hookSaved': case 'hookChanged': case 'hookDeleted': case 'hookItemOperateRendering': case 'addBlankPage': case 'editBlankPage': case 'disableCUD': case 'addDialogSize': case 'editDialogSize': return $this; } goto JanJS; W6rKP: return FieldManager::call($this, $WIVcd, $MVaFK); goto LF7Hu; JanJS: if ($this->isFluentAttribute($WIVcd)) { return $this->fluentAttribute($WIVcd, $MVaFK); } goto W6rKP; LF7Hu: } }