<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid; use ModStart\Grid\Filter\AbstractFilter; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Request; use ModStart\Grid\Filter\DatetimeRange; 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 ReflectionClass; class GridFilter { protected $model; protected $filters = array(); protected $supports = array('eq', 'like', 'likes', 'range'); private $field; private $search; private $fixedScopes; private $scopes; public function __construct(Model $pWRTh = null) { goto DJTQg; DJTQg: $this->model = $pWRTh; goto NsAlo; jfych: $this->scopes = collect(); goto mt8tb; NsAlo: $this->fixedScopes = collect(); goto jfych; mt8tb: } public function setSearch(array $hXd8h) { $this->search = $hXd8h; return $this; } public function fixScope() { goto kD3j2; jdkG_: $this->fixedScopes->push($AzFNm); goto QNknD; kD3j2: $AzFNm = new GridFilterScope($this); goto jdkG_; QNknD: return $AzFNm; goto z7kNJ; z7kNJ: } public function scope() { goto xSvL2; xSvL2: $AzFNm = new GridFilterScope($this); goto YqZF9; YqZF9: $this->scopes->push($AzFNm); goto SbQbK; SbQbK: return $AzFNm; goto xfJma; xfJma: } public function addFilter(AbstractFilter $cF9SB) { $cF9SB->setTableFilter($this); return $this->filters[] = $cF9SB; } public function clearFilter() { $this->filters = array(); } public function filters() { return $this->filters; } public function getConditions() { goto w301s; ivwDJ: $hXd8h = $this->search; goto f_TAH; w301s: $GjEhx = array(); goto ivwDJ; Z6yUO: return array_filter($GjEhx); goto NF4gu; f_TAH: if (!empty($hXd8h)) { while ($pnc_f = array_shift($hXd8h)) { foreach ($pnc_f as $o1X7E => $lp3Y2) { foreach ($this->filters() as $cF9SB) { if ($o1X7E === $cF9SB->column() && isset($lp3Y2[$cF9SB->name()])) { $eVURJ = $cF9SB->condition($lp3Y2); if (!empty($eVURJ)) { $sk8MQ = array_keys($eVURJ); if (count($sk8MQ) > 1 || count($sk8MQ) == 1 && $sk8MQ[0] === 0) { $GjEhx = array_merge($GjEhx, $eVURJ); } else { $GjEhx[] = $eVURJ; } } } } } } } goto Z6yUO; NF4gu: } public function execute() { $GjEhx = array_merge($this->getFixedScopeConditions(), $this->getScopeConditions(), $this->getConditions()); return $this->model->addConditions($GjEhx)->buildData(); } private function getFixedScopeConditions() { goto cLCrF; cLCrF: $GjEhx = $this->fixedScopes->map(function (GridFilterScope $AzFNm) { return $AzFNm->condition(); })->toArray(); goto Uv3CP; Uv3CP: if (empty($GjEhx)) { return array(); } goto qiYOq; qiYOq: return call_user_func_array('array_merge', $GjEhx); goto YV6dJ; YV6dJ: } private function getScopeConditions() { return array(); } public function __call($WIVcd, $MVaFK) { if (in_array($WIVcd, $this->supports)) { goto ejK6n; ejK6n: $Myw9a = '\\ModStart\\Grid\\Filter\\' . ucfirst($WIVcd); goto f7sYP; f7sYP: $JbDot = new ReflectionClass($Myw9a); goto scNqM; scNqM: return $this->addFilter($JbDot->newInstanceArgs($MVaFK)); goto x93Bs; x93Bs: } } }