<?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 $DRh9Q = null) { goto B76Ah; lMJTX: $this->scopes = collect(); goto dOwwD; eGmoc: $this->fixedScopes = collect(); goto lMJTX; B76Ah: $this->model = $DRh9Q; goto eGmoc; dOwwD: } public function setSearch(array $EspyQ) { $this->search = $EspyQ; return $this; } public function scope() { goto dS1By; VzQTM: $this->scopes->push($bLGF7); goto o6t9F; dS1By: $bLGF7 = new GridFilterScope($this); goto VzQTM; o6t9F: return $bLGF7; goto YC3DA; YC3DA: } public function addFilter(AbstractFilter $geg6A) { $geg6A->setTableFilter($this); return $this->filters[] = $geg6A; } public function clearFilter() { $this->filters = array(); } public function deleteFilterByColumn($mSZnY) { $this->filters = array_filter($this->filters, function ($geg6A) use($mSZnY) { return $geg6A->column() != $mSZnY; }); } public function filters() { return $this->filters; } public function hasAutoHideFilters() { foreach ($this->filters as $geg6A) { if ($geg6A->autoHide()) { return true; } } return false; } public function getConditions() { goto uAykO; T1goD: if (!empty($EspyQ)) { foreach ($EspyQ as $kUG7q) { if (!is_array($kUG7q)) { continue; } foreach ($kUG7q as $Xa4rs => $LDh4Z) { foreach ($this->filters() as $geg6A) { if ($Xa4rs === $geg6A->column() && isset($LDh4Z[$geg6A->name()])) { $QxPGP = $geg6A->condition($LDh4Z); if (!empty($QxPGP)) { $tLHPG = array_keys($QxPGP); if (count($tLHPG) > 1 || count($tLHPG) == 1 && $tLHPG[0] === 0) { $diux7 = array_merge($diux7, $QxPGP); } else { $diux7[] = $QxPGP; } } } } } } } goto rMD29; u1NTg: $EspyQ = $this->search; goto T1goD; rMD29: return array_filter($diux7); goto zLLSG; uAykO: $diux7 = array(); goto u1NTg; zLLSG: } public function executeQueryConditions($qeoqS) { goto lpW2h; yKymZ: foreach ($diux7 as $QxPGP) { $qeoqS = call_user_func_array(array($qeoqS, key($QxPGP)), current($QxPGP)); } goto nxBS4; lpW2h: $diux7 = array_merge($this->getScopeConditions(), $this->getConditions()); goto yKymZ; nxBS4: return $qeoqS; goto q00vp; q00vp: } public function executeQuery() { goto CB7sZ; Zyfmz: $this->model->clearQuery(); goto byiB8; CB7sZ: $diux7 = array_merge($this->getScopeConditions(), $this->getConditions()); goto Zyfmz; byiB8: return $this->model->addConditions($diux7)->getConditionQuery(); goto k4VVk; k4VVk: } public function execute() { goto X2pEb; kVJ5n: $this->model->clearQuery(); goto yHpJB; X2pEb: $diux7 = array_merge($this->getScopeConditions(), $this->getConditions()); goto kVJ5n; yHpJB: return $this->model->addConditions($diux7)->buildData(); goto r5GKU; r5GKU: } private function getScopeConditions() { return array(); } public function getSearch() { return $this->search; } public function __call($hiFdg, $lLyBI) { if (in_array($hiFdg, $this->supports)) { goto TR6LL; EcAjd: $geg6A = $fTZGT->newInstanceArgs($lLyBI); goto mtq1I; TR6LL: $QMs0F = '\\ModStart\\Grid\\Filter\\' . ucfirst($hiFdg); goto lCTEW; TVCKm: return $this->addFilter($geg6A); goto BxALq; mtq1I: if ($this->model) { $geg6A->grid($this->model->grid()); } goto TVCKm; lCTEW: $fTZGT = new ReflectionClass($QMs0F); goto EcAjd; BxALq: } } }