<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Filter; use Illuminate\Support\Facades\View; use ModStart\Core\Exception\BizException; use ModStart\Core\Util\IdUtil; use ModStart\Grid\Filter; use ModStart\Grid\Filter\Field\Text; use ModStart\Grid\Grid; use ModStart\Grid\GridFilter; use ModStart\Support\Concern\HasFluentAttribute; abstract class AbstractFilter { use HasFluentAttribute; private $fluentAttributes = array('hookRendering'); private $hookRendering; private $grid; protected $id; protected $label; protected $column; protected $field; protected $defaultValue; protected $query = 'where'; private $tableFilter; private $autoHide = false; public function __construct($JJepM, $Mbkw5 = '') { goto RGJy6; tfsi2: $this->column = $JJepM; goto xQMeZ; ZyBGi: $this->field->label($this->label); goto jSGko; hqWjH: $this->field = new Text($this); goto ZyBGi; xQMeZ: $this->label = $Mbkw5; goto hqWjH; RGJy6: $this->id = IdUtil::generate('GridFilter'); goto tfsi2; jSGko: } public function name() { $MsA2r = explode('\\', get_called_class()); return lcfirst(end($MsA2r)); } public function setTableFilter(GridFilter $udDBo) { $this->tableFilter = $udDBo; } public function condition($GWC6A) { if (isset($GWC6A['eq']) && $GWC6A['eq'] !== '') { return $this->buildCondition($this->column, '=', $GWC6A['eq']); } return null; } public function field($wvO30 = null) { goto t5fgS; ucD3Q: $this->field = $wvO30; goto oTUoj; oTUoj: return $this; goto IYSe4; t5fgS: if (null === $wvO30) { return $this->field; } goto ucD3Q; IYSe4: } public function defaultValue($wvO30) { $this->defaultValue = $wvO30; return $this; } public function autoHide($BWL_q = null) { goto z4BoS; wZ0hk: return $this; goto T7PcH; z4BoS: if (null === $BWL_q) { return $this->autoHide; } goto JEE3h; JEE3h: $this->autoHide = $BWL_q; goto wZ0hk; T7PcH: } public function column() { return $this->column; } protected function buildCondition() { goto rmE9x; NW0j0: if (count($JJepM) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto ieD43; rmE9x: $JJepM = explode('.', $this->column); goto NW0j0; ieD43: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto r02Zz; r02Zz: } protected function buildRelationCondition() { goto rcrAd; rcrAd: $wyd8_ = func_get_args(); goto GM6Ro; hYaOj: return array('whereHas' => array($MSYsA, function ($MSYsA) use($wyd8_) { call_user_func_array(array($MSYsA, $this->query), $wyd8_); })); goto sVftt; GM6Ro: list($MSYsA, $wyd8_[0]) = explode('.', $this->column); goto hYaOj; sVftt: } public function variables() { goto DJDJ3; DJDJ3: $oYeSv = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto oAJSu; L3S9s: return $oYeSv; goto kESTd; oAJSu: $oYeSv = array_merge($oYeSv, $this->field->variables()); goto L3S9s; kESTd: } public function render() { goto lsXta; Z3be1: $Etyzz = 'modstart::core.grid.filter.' . lcfirst(end($MsA2r)) . '-' . lcfirst(end($AQyl6)); goto BhIfX; LbG7g: $AQyl6 = explode('\\', get_class($this->field)); goto Z3be1; jhn_d: $MsA2r = explode('\\', get_called_class()); goto LbG7g; lsXta: if ($this->hookRendering instanceof \Closure) { $pTwJr = call_user_func($this->hookRendering, $this); if (null !== $pTwJr) { return $pTwJr; } } goto jhn_d; BhIfX: return View::make($Etyzz, $this->variables())->render(); goto y07zd; y07zd: } public function grid($xtA75 = null) { goto E7I3h; E7I3h: if (null === $xtA75) { return $this->grid; } goto iFndd; abCpx: return $this; goto boiNY; iFndd: $this->grid = $xtA75; goto abCpx; boiNY: } public function __call($L4owo, $nvZ9A) { if ($this->isFluentAttribute($L4owo)) { return $this->fluentAttribute($L4owo, $nvZ9A); } throw new \Exception('AbstractFilter __call error : ' . $L4owo); } }