<?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($mSZnY, $ldmKg = '') { goto GcgsP; m12vW: $this->column = $mSZnY; goto D40Y5; GcgsP: $this->id = IdUtil::generate('GridFilter'); goto m12vW; D40Y5: $this->label = $ldmKg; goto hNxYu; qgWH7: $this->field->label($this->label); goto uNnk5; hNxYu: $this->field = new Text($this); goto qgWH7; uNnk5: } public function name() { $GgiJ8 = explode('\\', get_called_class()); return lcfirst(end($GgiJ8)); } public function setTableFilter(GridFilter $geg6A) { $this->tableFilter = $geg6A; } public function condition($r8NJk) { if (isset($r8NJk['eq']) && $r8NJk['eq'] !== '') { return $this->buildCondition($this->column, '=', $r8NJk['eq']); } return null; } public function field($mdHu1 = null) { goto tZkHT; tZkHT: if (null === $mdHu1) { return $this->field; } goto WspeK; WspeK: $this->field = $mdHu1; goto OTk7X; OTk7X: return $this; goto Z6YD2; Z6YD2: } public function defaultValue($mdHu1) { $this->defaultValue = $mdHu1; return $this; } public function autoHide($R6yAX = null) { goto apcS3; lb_4_: return $this; goto ouAnz; INf_4: $this->autoHide = $R6yAX; goto lb_4_; apcS3: if (null === $R6yAX) { return $this->autoHide; } goto INf_4; ouAnz: } public function column() { return $this->column; } protected function buildCondition() { goto X4qAA; txNkr: if (count($mSZnY) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto XEMjI; X4qAA: $mSZnY = explode('.', $this->column); goto txNkr; XEMjI: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto W3fJX; W3fJX: } protected function buildRelationCondition() { goto dejkN; HFNU7: list($Jg55b, $hMgAl[0]) = explode('.', $this->column); goto ltlaT; dejkN: $hMgAl = func_get_args(); goto HFNU7; ltlaT: return array('whereHas' => array($Jg55b, function ($Jg55b) use($hMgAl) { call_user_func_array(array($Jg55b, $this->query), $hMgAl); })); goto snY0t; snY0t: } public function variables() { goto P63In; ABygs: return $z6iou; goto xsKr3; e9yZG: $z6iou = array_merge($z6iou, $this->field->variables()); goto ABygs; P63In: $z6iou = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto e9yZG; xsKr3: } public function render() { goto aJOqg; aJOqg: if ($this->hookRendering instanceof \Closure) { $N2Xaa = call_user_func($this->hookRendering, $this); if (null !== $N2Xaa) { return $N2Xaa; } } goto oG2eL; vhztJ: $d1G11 = 'modstart::core.grid.filter.' . lcfirst(end($GgiJ8)) . '-' . lcfirst(end($Yn_vl)); goto sccGD; mNpBo: $Yn_vl = explode('\\', get_class($this->field)); goto vhztJ; oG2eL: $GgiJ8 = explode('\\', get_called_class()); goto mNpBo; sccGD: return View::make($d1G11, $this->variables())->render(); goto W0bes; W0bes: } public function grid($jfjOt = null) { goto ZfzKv; ZfzKv: if (null === $jfjOt) { return $this->grid; } goto ec0Se; ec0Se: $this->grid = $jfjOt; goto ndISq; ndISq: return $this; goto cplX1; cplX1: } public function __call($c6VKG, $lLyBI) { if ($this->isFluentAttribute($c6VKG)) { return $this->fluentAttribute($c6VKG, $lLyBI); } throw new \Exception('AbstractFilter __call error : ' . $c6VKG); } }