<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid; use Illuminate\Support\Collection; use ModStart\Grid\Filter\AbstractFilter; use ModStart\Grid\Filter\Eq; use ModStart\Grid\Filter\Field\AbstractFilterField; use ModStart\Grid\Filter\Like; use ModStart\Grid\Filter\Likes; use ModStart\Grid\Filter\Range; use ModStart\Grid\Filter\Has; use ReflectionClass; class GridFilter { protected $model; protected $filters = array(); protected $supports = array('eq', 'like', 'likes', 'range', 'has'); private $field; private $search; private $scopes; public function __construct(Model $TAWWJ = null) { goto wOec9; GcMKd: $this->fixedScopes = collect(); goto A_zeR; A_zeR: $this->scopes = collect(); goto ydmPl; wOec9: $this->model = $TAWWJ; goto GcMKd; ydmPl: } public function setSearch(array $G4pdF) { $this->search = $G4pdF; return $this; } public function scope() { goto Ts3Em; nr2YW: $this->scopes->push($k709l); goto weI4R; weI4R: return $k709l; goto wUpnn; Ts3Em: $k709l = new GridFilterScope($this); goto nr2YW; wUpnn: } public function addFilter(AbstractFilter $JCV6U) { $JCV6U->setTableFilter($this); return $this->filters[] = $JCV6U; } public function clearFilter() { $this->filters = array(); } public function filters() { return $this->filters; } public function hasAutoHideFilters() { foreach ($this->filters as $JCV6U) { if ($JCV6U->autoHide()) { return true; } } return false; } public function getConditions() { goto AuctA; n1Laz: $G4pdF = $this->search; goto l1Lr0; AuctA: $KVlWj = array(); goto n1Laz; pQgvH: return array_filter($KVlWj); goto uFIFS; l1Lr0: if (!empty($G4pdF)) { foreach ($G4pdF as $Vb6Zd) { if (!is_array($Vb6Zd)) { continue; } foreach ($Vb6Zd as $IcWNM => $Th6yS) { foreach ($this->filters() as $JCV6U) { if ($IcWNM === $JCV6U->column() && isset($Th6yS[$JCV6U->name()])) { $t4qnT = $JCV6U->condition($Th6yS); if (!empty($t4qnT)) { $sBqI2 = array_keys($t4qnT); if (count($sBqI2) > 1 || count($sBqI2) == 1 && $sBqI2[0] === 0) { $KVlWj = array_merge($KVlWj, $t4qnT); } else { $KVlWj[] = $t4qnT; } } } } } } } goto pQgvH; uFIFS: } public function executeQuery() { goto IlwHq; IlwHq: $KVlWj = array_merge($this->getScopeConditions(), $this->getConditions()); goto BLWkx; ohq5_: return $this->model->addConditions($KVlWj)->getConditionQuery(); goto yRBIU; BLWkx: $this->model->clearQuery(); goto ohq5_; yRBIU: } public function execute() { goto gsz51; Bxhth: return $this->model->addConditions($KVlWj)->buildData(); goto dr95A; wZetP: $this->model->clearQuery(); goto Bxhth; gsz51: $KVlWj = array_merge($this->getScopeConditions(), $this->getConditions()); goto wZetP; dr95A: } private function getScopeConditions() { return array(); } public function getSearch() { return $this->search; } public function __call($JHYOH, $HPXJC) { if (in_array($JHYOH, $this->supports)) { goto KasEX; IT2gf: $JCV6U = $k4vG1->newInstanceArgs($HPXJC); goto Y9Top; uA3xq: $k4vG1 = new ReflectionClass($rgLyo); goto IT2gf; KasEX: $rgLyo = '\\ModStart\\Grid\\Filter\\' . ucfirst($JHYOH); goto uA3xq; NFFBI: return $this->addFilter($JCV6U); goto J8Xvy; Y9Top: $JCV6U->grid($this->model->grid()); goto NFFBI; J8Xvy: } } }