<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Filter; use ModStart\Core\Util\IdUtil; use ModStart\Grid\Filter; use ModStart\Grid\Filter\Field\Text; use ModStart\Grid\GridFilter; use ModStart\Support\Concern\HasFluentAttribute; abstract class AbstractFilter { use HasFluentAttribute; private $fluentAttributes = array('hookRendering'); private $hookRendering; private $id; private $label; protected $column; protected $field; protected $query = 'where'; private $tableFilter; public function __construct($JNXBz, $lPHIy = '') { goto PCTWs; PCTWs: $this->id = IdUtil::generate('GridFilter'); goto KVThC; KVThC: $this->column = $JNXBz; goto cUTmv; VV5Vq: $this->field->label($this->label); goto S7zpO; cUTmv: $this->label = $lPHIy; goto eoOCA; eoOCA: $this->field = new Text($this); goto VV5Vq; S7zpO: } public function name() { $StsmC = explode('\\', get_called_class()); return lcfirst(end($StsmC)); } public function setTableFilter(GridFilter $cF9SB) { $this->tableFilter = $cF9SB; } public function condition($xVdRy) { if (isset($xVdRy['eq']) && $xVdRy['eq'] !== '') { return $this->buildCondition($this->column, '=', $xVdRy['eq']); } return null; } public function field($tzAUI = null) { if (null === $tzAUI) { return $this->field; } $this->field = $tzAUI; } public function column() { return $this->column; } protected function buildCondition() { goto eOgek; czzSd: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto Km0_n; nRHAJ: if (count($JNXBz) == 1) { return array($this->query => func_get_args()); } goto czzSd; eOgek: $JNXBz = explode('.', $this->column); goto nRHAJ; Km0_n: } protected function buildRelationCondition() { goto oBWpE; cdcbf: return array('whereHas' => array($XoyfF, function ($XoyfF) use($RTmZV) { call_user_func_array(array($XoyfF, $this->query), $RTmZV); })); goto KoIMx; oBWpE: $RTmZV = func_get_args(); goto g65Yh; g65Yh: list($XoyfF, $RTmZV[0]) = explode('.', $this->column); goto cdcbf; KoIMx: } private function variables() { goto Fni9a; PubIX: if (method_exists($this->field, 'variables')) { $t3Kum = array_merge($t3Kum, $this->field()->variables()); } goto DsyQU; DsyQU: return $t3Kum; goto vA22q; Fni9a: $t3Kum = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field); goto PubIX; vA22q: } public function render() { goto WXas2; fE1LZ: $StsmC = explode('\\', get_called_class()); goto i42jt; ILM0m: $cBZiy = 'modstart::core.grid.filter.' . lcfirst(end($StsmC)) . '-' . lcfirst(end($fRGjA)); goto yASRe; i42jt: $fRGjA = explode('\\', get_class($this->field)); goto ILM0m; WXas2: if ($this->hookRendering instanceof \Closure) { $uotzZ = call_user_func($this->hookRendering, $this); if (null !== $uotzZ) { return $uotzZ; } } goto fE1LZ; yASRe: return view($cBZiy, $this->variables()); goto awzGJ; awzGJ: } public function __call($TUuqF, $MVaFK) { if ($this->isFluentAttribute($TUuqF)) { return $this->fluentAttribute($TUuqF, $MVaFK); } throw new \Exception('AbstractFilter __call error : ' . $TUuqF); } }