<?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($xyEtj) { $this->addVariables(array('server' => $xyEtj)); return $this; } public function viewWithModel($Y2RbY, $xq04r = 'id', $gYbZ7 = 'title') { $this->hookRendering(function (AbstractField $pu1ro, $V563N, $aDVv6) use($Y2RbY, $xq04r, $gYbZ7) { switch ($pu1ro->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto HuoIG; HuoIG: $ib3B9 = $V563N[$pu1ro->name()]; goto meE9b; tqEvT: if ($H7gaA) { $ib3B9 = $H7gaA[$gYbZ7]; } goto PzeOg; PzeOg: return AutoRenderedFieldValue::make($ib3B9); goto Xk9X5; meE9b: $H7gaA = ModelUtil::get($Y2RbY, array($xq04r => $ib3B9)); goto tqEvT; Xk9X5: } }); return $this; } public static function handleModel($Y2RbY, $xq04r = 'id', $gYbZ7 = 'title', $pmJAc = array()) { goto aYfvL; LJ2mo: $ib3B9 = $do_OL->getInteger('value'); goto rq5aJ; M5Msu: if ($ib3B9) { $xaAIg = $xaAIg->where($xq04r, $ib3B9); } goto ZFWTe; rq5aJ: $ro4O3 = $do_OL->getTrimString('keywords'); goto XqugZ; xokZF: $atZJ8 = array(); goto NCgRx; aYfvL: if (!isset($pmJAc['sort'])) { $pmJAc['sort'] = array('id', 'desc'); } goto PcPhO; PcPhO: $do_OL = InputPackage::buildFromInput(); goto LJ2mo; pdrT9: $laNjB = $xaAIg->orderBy($pmJAc['sort'][0], $pmJAc['sort'][1])->limit(10)->get(array($xq04r, $gYbZ7))->toArray(); goto xokZF; dY2dV: return Response::generateSuccessData(array('options' => $atZJ8)); goto jvssb; ZFWTe: if ($ro4O3) { $xaAIg = $xaAIg->where($gYbZ7, 'like', '%' . $ro4O3 . '%'); } goto pdrT9; XqugZ: $xaAIg = ModelUtil::model($Y2RbY); goto M5Msu; NCgRx: foreach ($laNjB as $H7gaA) { $atZJ8[] = array('value' => $H7gaA[$xq04r], 'label' => $H7gaA[$gYbZ7]); } goto dY2dV; jvssb: } }