<?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($XrXh2, $y1zAr = '') { goto yiNTZ; CFsbF: $this->field = new Text($this); goto bMelp; bMelp: $this->field->label($this->label); goto zOeMQ; uqjs3: $this->label = $y1zAr; goto CFsbF; TlEu5: $this->column = $XrXh2; goto uqjs3; yiNTZ: $this->id = IdUtil::generate('GridFilter'); goto TlEu5; zOeMQ: } public function name() { $cl6c3 = explode('\\', get_called_class()); return lcfirst(end($cl6c3)); } public function setTableFilter(GridFilter $CJNWc) { $this->tableFilter = $CJNWc; } public function condition($cGzJA) { if (isset($cGzJA['eq']) && $cGzJA['eq'] !== '') { return $this->buildCondition($this->column, '=', $cGzJA['eq']); } return null; } public function field($gwXrh = null) { goto j9Nz9; vxwX0: $this->field = $gwXrh; goto tuE8v; j9Nz9: if (null === $gwXrh) { return $this->field; } goto vxwX0; tuE8v: return $this; goto NxxQw; NxxQw: } public function defaultValue($gwXrh) { $this->defaultValue = $gwXrh; return $this; } public function autoHide($DC7j2 = null) { goto kRZxg; Ni_3R: return $this; goto EXzoa; Z4WzH: $this->autoHide = $DC7j2; goto Ni_3R; kRZxg: if (null === $DC7j2) { return $this->autoHide; } goto Z4WzH; EXzoa: } public function column() { return $this->column; } protected function buildCondition() { goto bxUj8; GTdBz: if (count($XrXh2) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto bPPEH; bxUj8: $XrXh2 = explode('.', $this->column); goto GTdBz; bPPEH: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto f6_ik; f6_ik: } protected function buildRelationCondition() { goto Vprwv; h76PY: list($Au36E, $pdeSd[0]) = explode('.', $this->column); goto TCW7_; TCW7_: return array('whereHas' => array($Au36E, function ($Au36E) use($pdeSd) { call_user_func_array(array($Au36E, $this->query), $pdeSd); })); goto p39YE; Vprwv: $pdeSd = func_get_args(); goto h76PY; p39YE: } public function variables() { goto hNhRh; WZt5P: return $D6v2W; goto hQN6X; SaC1s: $D6v2W = array_merge($D6v2W, $this->field->variables()); goto WZt5P; hNhRh: $D6v2W = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto SaC1s; hQN6X: } public function render() { goto cqaws; D1dAm: $cl6c3 = explode('\\', get_called_class()); goto hT3yv; LmwuV: return View::make($EdxNA, $this->variables())->render(); goto ZqrgD; hT3yv: $lTZsl = explode('\\', get_class($this->field)); goto IJGeX; IJGeX: $EdxNA = 'modstart::core.grid.filter.' . lcfirst(end($cl6c3)) . '-' . lcfirst(end($lTZsl)); goto LmwuV; cqaws: if ($this->hookRendering instanceof \Closure) { $UdQ1p = call_user_func($this->hookRendering, $this); if (null !== $UdQ1p) { return $UdQ1p; } } goto D1dAm; ZqrgD: } public function grid($fvhtX = null) { goto JSbje; M_Ujk: $this->grid = $fvhtX; goto V3Yiu; V3Yiu: return $this; goto cj0Lx; JSbje: if (null === $fvhtX) { return $this->grid; } goto M_Ujk; cj0Lx: } public function __call($L1g9F, $CUZy6) { if ($this->isFluentAttribute($L1g9F)) { return $this->fluentAttribute($L1g9F, $CUZy6); } throw new \Exception('AbstractFilter __call error : ' . $L1g9F); } }