<?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($VDtGk, $rhrTz = '') { goto cCdAQ; cCdAQ: $this->id = IdUtil::generate('GridFilter'); goto TtYn_; CHAG2: $this->field = new Text($this); goto KdkDB; TtYn_: $this->column = $VDtGk; goto fMBuy; KdkDB: $this->field->label($this->label); goto aNMH5; fMBuy: $this->label = $rhrTz; goto CHAG2; aNMH5: } public function name() { $cTFJ4 = explode('\\', get_called_class()); return lcfirst(end($cTFJ4)); } public function setTableFilter(GridFilter $z8oGH) { $this->tableFilter = $z8oGH; } public function condition($JnEKk) { if (isset($JnEKk['eq']) && $JnEKk['eq'] !== '') { return $this->buildCondition($this->column, '=', $JnEKk['eq']); } return null; } public function field($Gttsd = null) { goto VyA_j; EScgg: $this->field = $Gttsd; goto Wa3tL; Wa3tL: return $this; goto E4TJo; VyA_j: if (null === $Gttsd) { return $this->field; } goto EScgg; E4TJo: } public function defaultValue($Gttsd) { $this->defaultValue = $Gttsd; return $this; } public function autoHide($nl2sJ = null) { goto GGIz6; lGnoc: $this->autoHide = $nl2sJ; goto PlYe1; PlYe1: return $this; goto bnwsa; GGIz6: if (null === $nl2sJ) { return $this->autoHide; } goto lGnoc; bnwsa: } public function column() { return $this->column; } protected function buildCondition() { goto NK9UJ; NK9UJ: $VDtGk = explode('.', $this->column); goto YR0l1; guKZB: return call_user_func_array(array($this, 'buildRelationCondition'), func_get_args()); goto Zw2yg; YR0l1: if (count($VDtGk) == 1 || $this->grid->isDynamicModel()) { return array($this->query => func_get_args()); } goto guKZB; Zw2yg: } protected function buildRelationCondition() { goto PLl3I; PLl3I: $d9ApU = func_get_args(); goto or9Hs; or9Hs: list($wH8CE, $d9ApU[0]) = explode('.', $this->column); goto u4obE; u4obE: return array('whereHas' => array($wH8CE, function ($wH8CE) use($d9ApU) { call_user_func_array(array($wH8CE, $this->query), $d9ApU); })); goto hfC1x; hfC1x: } public function variables() { goto Lk1UE; zwU5T: return $w_e8L; goto z_83h; Z0qoh: $w_e8L = array_merge($w_e8L, $this->field->variables()); goto zwU5T; Lk1UE: $w_e8L = array('id' => $this->id, 'column' => $this->column, 'label' => $this->label, 'field' => $this->field, 'defaultValue' => $this->defaultValue, 'autoHide' => $this->autoHide); goto Z0qoh; z_83h: } public function render() { goto c8vJD; fTKKo: $cTFJ4 = explode('\\', get_called_class()); goto fVDow; GtqZS: return View::make($XlNhR, $this->variables())->render(); goto bC3Ti; fVDow: $m39L9 = explode('\\', get_class($this->field)); goto iEJrR; iEJrR: $XlNhR = 'modstart::core.grid.filter.' . lcfirst(end($cTFJ4)) . '-' . lcfirst(end($m39L9)); goto GtqZS; c8vJD: if ($this->hookRendering instanceof \Closure) { $f3Nqc = call_user_func($this->hookRendering, $this); if (null !== $f3Nqc) { return $f3Nqc; } } goto fTKKo; bC3Ti: } public function grid($TzF5r = null) { goto nV4Yy; SsK0_: $this->grid = $TzF5r; goto o2Ms3; o2Ms3: return $this; goto LZC16; nV4Yy: if (null === $TzF5r) { return $this->grid; } goto SsK0_; LZC16: } public function __call($sQIr6, $g59Hh) { if ($this->isFluentAttribute($sQIr6)) { return $this->fluentAttribute($sQIr6, $g59Hh); } throw new \Exception('AbstractFilter __call error : ' . $sQIr6); } }