<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use ModStart\Grid\Filter\AbstractFilter; use ModStart\Grid\Filter\Eq; use ModStart\Grid\Filter\Field\AbstractFilterField; use ModStart\Grid\Filter\Has; use ModStart\Grid\Filter\Like; use ModStart\Grid\Filter\Likes; use ModStart\Grid\Filter\Range; 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 $GMqtO = null) { goto BT9D9; BT9D9: $this->model = $GMqtO; goto ntiHc; eG13B: $this->scopes = collect(); goto p559W; ntiHc: $this->fixedScopes = collect(); goto eG13B; p559W: } public function setSearch(array $fKAnl) { $this->search = $fKAnl; return $this; } public function scope() { goto BIf_K; Hsjf6: $this->scopes->push($EF8S3); goto QPl7b; BIf_K: $EF8S3 = new GridFilterScope($this); goto Hsjf6; QPl7b: return $EF8S3; goto uD2yK; uD2yK: } public function addFilter(AbstractFilter $DMbpM) { $DMbpM->setTableFilter($this); return $this->filters[] = $DMbpM; } public function clearFilter() { $this->filters = array(); } public function deleteFilterByColumn($GR5Ef) { $this->filters = array_filter($this->filters, function ($DMbpM) use($GR5Ef) { return $DMbpM->column() != $GR5Ef; }); } public function filters() { return $this->filters; } public function hasAutoHideFilters() { foreach ($this->filters as $DMbpM) { if ($DMbpM->autoHide()) { return true; } } return false; } public function getConditions() { goto pUihI; pUihI: $kSBZ4 = array(); goto buQt0; DoKJP: if (!empty($fKAnl)) { foreach ($fKAnl as $rodjK) { if (!is_array($rodjK)) { continue; } foreach ($rodjK as $cbvI_ => $fD5rP) { foreach ($this->filters() as $DMbpM) { if ($cbvI_ === $DMbpM->column() && isset($fD5rP[$DMbpM->name()])) { $xJZLL = $DMbpM->condition($fD5rP); if (!empty($xJZLL)) { $y9Lyp = array_keys($xJZLL); if (count($y9Lyp) > 1 || count($y9Lyp) == 1 && $y9Lyp[0] === 0) { $kSBZ4 = array_merge($kSBZ4, $xJZLL); } else { $kSBZ4[] = $xJZLL; } } } } } } } goto Zc1VC; buQt0: $fKAnl = $this->search; goto DoKJP; Zc1VC: return array_filter($kSBZ4); goto N7kxk; N7kxk: } public function executeQueryConditions($nYIOS) { goto qTjqx; qTjqx: $kSBZ4 = array_merge($this->getScopeConditions(), $this->getConditions()); goto Z7ho8; dvb5c: return $nYIOS; goto CC3td; Z7ho8: foreach ($kSBZ4 as $xJZLL) { $nYIOS = call_user_func_array(array($nYIOS, key($xJZLL)), current($xJZLL)); } goto dvb5c; CC3td: } public function executeQuery() { goto OSPsM; k8pP5: $this->model->clearQuery(); goto l1BCy; OSPsM: $kSBZ4 = array_merge($this->getScopeConditions(), $this->getConditions()); goto k8pP5; l1BCy: return $this->model->addConditions($kSBZ4)->getConditionQuery(); goto yGf04; yGf04: } public function execute() { goto Atgzj; Atgzj: $kSBZ4 = array_merge($this->getScopeConditions(), $this->getConditions()); goto gMFoL; FK403: return $this->model->addConditions($kSBZ4)->buildData(); goto I9zH5; gMFoL: $this->model->clearQuery(); goto FK403; I9zH5: } private function getScopeConditions() { return array(); } public function getSearch() { return $this->search; } public function __call($UVOMF, $bY7Wp) { if (in_array($UVOMF, $this->supports)) { goto R29Lb; qvX5N: $DMbpM = $LWcTV->newInstanceArgs($bY7Wp); goto mXvqi; JUY59: $LWcTV = new ReflectionClass($rTMUX); goto qvX5N; R29Lb: $rTMUX = '\\ModStart\\Grid\\Filter\\' . ucfirst($UVOMF); goto JUY59; k9uxc: return $this->addFilter($DMbpM); goto IQIFg; mXvqi: if ($this->model) { $DMbpM->grid($this->model->grid()); } goto k9uxc; IQIFg: } } }