<?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($xiZoD, $ob1v7 = '') { goto kvRro; kvRro: $this->id = IdUtil::generate('GridFilter'); goto acTaj; acTaj: $this->column = $xiZoD; goto PO37v; Pb127: $this->field->label($this->label); goto yD0yM; PO37v: $this->label = $ob1v7; goto c6jyD; c6jyD: $this->field = new Text($this); goto Pb127; yD0yM: } public function name() { $AEqP7 = explode('\\', get_called_class()); return lcfirst(end($AEqP7)); } public function setTableFilter(GridFilter $pvsQp) { $this->tableFilter = $pvsQp; } public function condition($ZYqjI) { if (isset($ZYqjI['eq']) && $ZYqjI['eq'] !== '') { return $this->buildCondition($this->column, '=', $ZYqjI['eq']); } return null; } public function field($ib3B9 = null) { goto pRQ3S; MZywu: return $this; goto xpNpU; pWFSh: $this->field = $ib3B9; goto MZywu; pRQ3S: if (null === $ib3B9) { return $this->field; } goto pWFSh; xpNpU: } public function defaultValue($ib3B9) { $this->defaultValue = $ib3B9; return $this; } public function autoHide($TeN6d = null) { goto u5VZh; u5VZh: if (null === $TeN6d) { return $this->autoHide; } goto aPdSn; aPdSn: $this->autoHide = $TeN6d; goto emTd7; emTd7: return $this; goto xEYS0; xEYS0: } public function column() { return $this->column; } protected function buildCondition() { goto ljMuj; PrRbj: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto j1Hzb; U2Xan: if (count($xiZoD) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto PrRbj; ljMuj: $xiZoD = explode('.', $this->column); goto U2Xan; j1Hzb: } protected function buildRelationCondition() { goto tT5RG; lcuqz: list($T0xhH, $ilVXN[0]) = explode('.', $this->column); goto qqjgO; tT5RG: $ilVXN = func_get_args(); goto lcuqz; qqjgO: return array('whereHas' => array($T0xhH, function ($T0xhH) use($ilVXN) { call_user_func_array(array($T0xhH, $this->query), $ilVXN); })); goto tWsgH; tWsgH: } public function variables() { goto N2_ps; bFBxJ: $XZNiG = array_merge($XZNiG, $this->field->variables()); goto U7zOQ; N2_ps: $XZNiG = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto bFBxJ; U7zOQ: return $XZNiG; goto YHrhv; YHrhv: } public function render() { goto fSLmE; fSLmE: if ($this->hookRendering instanceof \Closure) { $gbVzz = call_user_func($this->hookRendering, $this); if (null !== $gbVzz) { return $gbVzz; } } goto ZGPzW; MlfzV: $iZpId = explode('\\', get_class($this->field)); goto nrMOz; ZGPzW: $AEqP7 = explode('\\', get_called_class()); goto MlfzV; nrMOz: $WDpfu = 'modstart::core.grid.filter.' . lcfirst(end($AEqP7)) . '-' . lcfirst(end($iZpId)); goto lmhwz; lmhwz: return View::make($WDpfu, $this->variables())->render(); goto v40Ja; v40Ja: } public function grid($BtYIX = null) { goto A_R3t; A_R3t: if (null === $BtYIX) { return $this->grid; } goto aXzOf; aXzOf: $this->grid = $BtYIX; goto Lrx12; Lrx12: return $this; goto EXUJ4; EXUJ4: } public function __call($XggBq, $lUGZC) { if ($this->isFluentAttribute($XggBq)) { return $this->fluentAttribute($XggBq, $lUGZC); } throw new \Exception('AbstractFilter __call error : ' . $XggBq); } }