41 lines
684 B
PHP
41 lines
684 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\DB\Te;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Created by PhpStorm.
|
||
|
|
* User: AraNote
|
||
|
|
* Date: 12/04/2018
|
||
|
|
* Time: 10:34 PM
|
||
|
|
*/
|
||
|
|
class Scope
|
||
|
|
{
|
||
|
|
public $items, $query;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Scope constructor.
|
||
|
|
* @param $items
|
||
|
|
*/
|
||
|
|
public function __construct($query, $items)
|
||
|
|
{
|
||
|
|
$this->query = $query;
|
||
|
|
$this->items = $items;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public static function init($query, $items)
|
||
|
|
{
|
||
|
|
return new Scope($query, $items);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public function run()
|
||
|
|
{
|
||
|
|
foreach ($this->items as $index => $item) {
|
||
|
|
Filter::init($this->query, $item, $index == 0)->run();
|
||
|
|
}
|
||
|
|
// dd($this->query->toSql());
|
||
|
|
return $this->query;
|
||
|
|
}
|
||
|
|
}
|