<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Field\Concern\CanCascadeFields; use ModStart\Field\Type\FieldRenderMode; class SelectRemote extends AbstractField { use CanCascadeFields; protected function setup() { $this->addVariables(array('server' => '')); } public function server($YSNPl) { $this->addVariables(array('server' => $YSNPl)); return $this; } public function viewWithModel($wyCKK, $ic5c_ = 'id', $vWMJh = 'title') { $this->hookRendering(function (AbstractField $E8QRJ, $OV1o4, $xlsSz) use($wyCKK, $ic5c_, $vWMJh) { switch ($E8QRJ->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto bgQd8; bgQd8: $HDpl6 = $OV1o4[$E8QRJ->name()]; goto BUeSF; iGgIJ: if ($kwA4W) { $HDpl6 = $kwA4W[$vWMJh]; } goto V0Pbv; V0Pbv: return AutoRenderedFieldValue::make($HDpl6); goto PFyNQ; BUeSF: $kwA4W = ModelUtil::get($wyCKK, array($ic5c_ => $HDpl6)); goto iGgIJ; PFyNQ: } }); return $this; } public static function handleModel($wyCKK, $ic5c_ = 'id', $vWMJh = 'title', $AXgEz = array()) { goto IfQiV; az6hr: $sYsuI = InputPackage::buildFromInput(); goto DzFJI; itmHm: if ($DtcC9) { $vw3jY = $vw3jY->where($vWMJh, 'like', '%' . $DtcC9 . '%'); } goto w9934; Mm6g2: return Response::generateSuccessData(array('options' => $Bodfy)); goto duqoM; IfQiV: if (!isset($AXgEz['sort'])) { $AXgEz['sort'] = array('id', 'desc'); } goto az6hr; DzFJI: $HDpl6 = $sYsuI->getInteger('value'); goto CQczJ; CQczJ: $DtcC9 = $sYsuI->getTrimString('keywords'); goto gN8iW; LnuP9: if ($HDpl6) { $vw3jY = $vw3jY->where($ic5c_, $HDpl6); } goto itmHm; gN8iW: $vw3jY = ModelUtil::model($wyCKK); goto LnuP9; AmPl6: foreach ($lz_pk as $kwA4W) { $Bodfy[] = array('value' => $kwA4W[$ic5c_], 'label' => $kwA4W[$vWMJh]); } goto Mm6g2; w9934: $lz_pk = $vw3jY->orderBy($AXgEz['sort'][0], $AXgEz['sort'][1])->limit(10)->get(array($ic5c_, $vWMJh))->toArray(); goto ntGGd; ntGGd: $Bodfy = array(); goto AmPl6; duqoM: } }