<?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($pEs5l, \Closure $KqSwj = null) { goto CifPB; xvGtA: $this->builder($KqSwj); goto CtNBZ; X717K: $this->fieldDefaultRenderMode(FieldRenderMode::DETAIL); goto lX7iL; CifPB: $this->id = IdUtil::generate('Grid'); goto FxxPr; j2HPA: $this->setupFields(); goto X717K; FxxPr: $this->repository = Repository::instance($pEs5l); goto j2HPA; lX7iL: $this->setupRepositoryFilter(); goto xvGtA; CtNBZ: } public static function make($BWo2e, \Closure $KqSwj = null) { if (is_object($BWo2e) || class_exists($BWo2e) && is_subclass_of($BWo2e, Model::class)) { return new Detail($BWo2e, $KqSwj); } return new Detail(DynamicModel::make($BWo2e), $KqSwj); } public function asTree($AWXu8 = 'id', $LdK4t = 'pid', $xleCl = 'sort', $HPS0I = 'title') { goto Ig19r; xTyl_: $this->engine = DetailEngine::TREE; goto GB0nX; IhA8_: $this->repository->setSortColumn($xleCl); goto GIcvR; GIcvR: $this->repository->setTreeTitleColumn($HPS0I); goto xTyl_; Ig19r: $this->repository->setKeyName($AWXu8); goto jGXzG; jGXzG: $this->repository->setTreePidColumn($LdK4t); goto IhA8_; GB0nX: return $this; goto EV9T9; EV9T9: } public function asTreeMass($veSD3 = 0, $AWXu8 = 'id', $LdK4t = 'pid', $xleCl = 'sort', $HPS0I = 'title') { goto qWg2X; qWg2X: $this->repository->setKeyName($AWXu8); goto txg5q; f_5J2: return $this; goto rVRDA; txg5q: $this->repository->setTreePidColumn($LdK4t); goto nf52s; sNV48: $this->repository->setTreeTitleColumn($HPS0I); goto yuYWo; yuYWo: $this->engine = DetailEngine::TREE_MASS; goto f_5J2; nf52s: $this->repository->setSortColumn($xleCl); goto sNV48; rVRDA: } public function repository() { return $this->repository; } private function build() { $this->runBuilder(); } public function show($T6TGt) { goto Pe9bS; kPk8j: $this->item($this->repository()->show($this)); goto TTIAs; MJ_xT: $this->fillFields(); goto FdhAP; Pe9bS: $this->itemId($T6TGt); goto kPk8j; TTIAs: BizException::throwsIfEmpty(L('Record Not Exists'), $this->item); goto OhLL0; OhLL0: $this->build(); goto MJ_xT; FdhAP: return $this; goto o6Xrf; o6Xrf: } public function render() { goto Nq6r1; PELwQ: return view($this->view, $CnWtd)->render(); goto aqokW; Nq6r1: $CnWtd = array(); goto twPNi; twPNi: $CnWtd['fields'] = $this->showableFields(); goto km_ro; km_ro: $CnWtd = array_merge($this->fluentAttributeVariables(), $CnWtd); goto PELwQ; aqokW: } public function __call($fSCUf, $g59Hh) { goto l3Xaf; QwXBr: return FieldManager::call($this, $fSCUf, $g59Hh); goto j3aPG; uvl0Z: if ($this->isFluentAttribute($fSCUf)) { return $this->fluentAttribute($fSCUf, $g59Hh); } goto QwXBr; l3Xaf: switch ($fSCUf) { 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 uvl0Z; j3aPG: } public function __toString() { try { return $this->render(); } catch (\Exception $WVwSN) { return $WVwSN->getMessage(); } } }