<?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($GR5Ef, $JqDEI = '') { goto zMWtj; hCikA: $this->field->label($this->label); goto RZQjh; Igoj8: $this->column = $GR5Ef; goto orayB; pqnSm: $this->field = new Text($this); goto hCikA; zMWtj: $this->id = IdUtil::generate('GridFilter'); goto Igoj8; orayB: $this->label = $JqDEI; goto pqnSm; RZQjh: } public function name() { $t7pan = explode('\\', get_called_class()); return lcfirst(end($t7pan)); } public function setTableFilter(GridFilter $DMbpM) { $this->tableFilter = $DMbpM; } public function condition($u0mCd) { if (isset($u0mCd['eq']) && $u0mCd['eq'] !== '') { return $this->buildCondition($this->column, '=', $u0mCd['eq']); } return null; } public function field($cBDsM = null) { goto y43kn; y43kn: if (null === $cBDsM) { return $this->field; } goto tQ8rp; DWtre: return $this; goto anMoo; tQ8rp: $this->field = $cBDsM; goto DWtre; anMoo: } public function defaultValue($cBDsM) { $this->defaultValue = $cBDsM; return $this; } public function autoHide($I5i6d = null) { goto HVKig; lLGtW: return $this; goto E3ZLe; EocTQ: $this->autoHide = $I5i6d; goto lLGtW; HVKig: if (null === $I5i6d) { return $this->autoHide; } goto EocTQ; E3ZLe: } public function column() { return $this->column; } protected function buildCondition() { goto dzGit; WfP0Z: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto bdXb9; dzGit: $GR5Ef = explode('.', $this->column); goto PDEC7; PDEC7: if (count($GR5Ef) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto WfP0Z; bdXb9: } protected function buildRelationCondition() { goto KEmZb; b8vea: list($N2EVc, $WdGpR[0]) = explode('.', $this->column); goto vzdHD; vzdHD: return array('whereHas' => array($N2EVc, function ($N2EVc) use($WdGpR) { call_user_func_array(array($N2EVc, $this->query), $WdGpR); })); goto Ry8b7; KEmZb: $WdGpR = func_get_args(); goto b8vea; Ry8b7: } public function variables() { goto HquGC; ukI0L: $YVA52 = array_merge($YVA52, $this->field->variables()); goto yXrHd; HquGC: $YVA52 = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto ukI0L; yXrHd: return $YVA52; goto yA_2o; yA_2o: } public function render() { goto K6GZ_; mA5Bm: $lGesZ = explode('\\', get_class($this->field)); goto m6BtK; hfepL: return View::make($Y65Gr, $this->variables())->render(); goto n5VtV; m6BtK: $Y65Gr = 'modstart::core.grid.filter.' . lcfirst(end($t7pan)) . '-' . lcfirst(end($lGesZ)); goto hfepL; U2For: $t7pan = explode('\\', get_called_class()); goto mA5Bm; K6GZ_: if ($this->hookRendering instanceof \Closure) { $bCCWW = call_user_func($this->hookRendering, $this); if (null !== $bCCWW) { return $bCCWW; } } goto U2For; n5VtV: } public function grid($H0Ja4 = null) { goto Z26YV; xmIw0: return $this; goto vEafJ; KV4Cc: $this->grid = $H0Ja4; goto xmIw0; Z26YV: if (null === $H0Ja4) { return $this->grid; } goto KV4Cc; vEafJ: } public function __call($glP3G, $bY7Wp) { if ($this->isFluentAttribute($glP3G)) { return $this->fluentAttribute($glP3G, $bY7Wp); } throw new \Exception('AbstractFilter __call error : ' . $glP3G); } }