<?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($t_tdX, $AqEmT = '') { goto VZv34; s3XML: $this->field->label($this->label); goto tZlhg; zkiby: $this->column = $t_tdX; goto PaK0M; VZv34: $this->id = IdUtil::generate('GridFilter'); goto zkiby; PaK0M: $this->label = $AqEmT; goto qLyj8; qLyj8: $this->field = new Text($this); goto s3XML; tZlhg: } public function name() { $ogfq7 = explode('\\', get_called_class()); return lcfirst(end($ogfq7)); } public function setTableFilter(GridFilter $Nxn6E) { $this->tableFilter = $Nxn6E; } public function condition($AgbcE) { if (isset($AgbcE['eq']) && $AgbcE['eq'] !== '') { return $this->buildCondition($this->column, '=', $AgbcE['eq']); } return null; } public function field($Mczr_ = null) { goto sCM7x; sCM7x: if (null === $Mczr_) { return $this->field; } goto gTJjv; gTJjv: $this->field = $Mczr_; goto iHvAd; iHvAd: return $this; goto U5Z2x; U5Z2x: } public function defaultValue($Mczr_) { $this->defaultValue = $Mczr_; return $this; } public function autoHide($rRTv3 = null) { goto bBfcc; rgtyz: return $this; goto Pudsy; LiL3X: $this->autoHide = $rRTv3; goto rgtyz; bBfcc: if (null === $rRTv3) { return $this->autoHide; } goto LiL3X; Pudsy: } public function column() { return $this->column; } protected function buildCondition() { goto EtZfR; XXzjJ: if (count($t_tdX) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto k0Tj_; k0Tj_: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto eaLyC; EtZfR: $t_tdX = explode('.', $this->column); goto XXzjJ; eaLyC: } protected function buildRelationCondition() { goto R_we6; d3u_e: return array('whereHas' => array($nHUGv, function ($nHUGv) use($v10GK) { call_user_func_array(array($nHUGv, $this->query), $v10GK); })); goto Mz652; R_we6: $v10GK = func_get_args(); goto r9TkK; r9TkK: list($nHUGv, $v10GK[0]) = explode('.', $this->column); goto d3u_e; Mz652: } public function variables() { goto R27gQ; JXJ5_: $qZY2j = array_merge($qZY2j, $this->field->variables()); goto K4XLd; K4XLd: return $qZY2j; goto TJoKV; R27gQ: $qZY2j = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto JXJ5_; TJoKV: } public function render() { goto z4SbC; rFZhX: $yqF4x = explode('\\', get_class($this->field)); goto t4xsc; z4SbC: if ($this->hookRendering instanceof \Closure) { $ZIe4d = call_user_func($this->hookRendering, $this); if (null !== $ZIe4d) { return $ZIe4d; } } goto OtDQ0; u9asV: return View::make($FOcXW, $this->variables())->render(); goto dcxj0; OtDQ0: $ogfq7 = explode('\\', get_called_class()); goto rFZhX; t4xsc: $FOcXW = 'modstart::core.grid.filter.' . lcfirst(end($ogfq7)) . '-' . lcfirst(end($yqF4x)); goto u9asV; dcxj0: } public function grid($FGotH = null) { goto whjE3; whjE3: if (null === $FGotH) { return $this->grid; } goto xBnUN; xBnUN: $this->grid = $FGotH; goto bYv5U; bYv5U: return $this; goto zIuXI; zIuXI: } public function __call($ZZMEd, $rxS2C) { if ($this->isFluentAttribute($ZZMEd)) { return $this->fluentAttribute($ZZMEd, $rxS2C); } throw new \Exception('AbstractFilter __call error : ' . $ZZMEd); } }