1
0
mirror of https://github.com/robonen/education-project.git synced 2026-03-20 02:44:31 +00:00

Создание, обновление, получение, фильтрация

This commit is contained in:
nikden13
2020-12-04 11:09:57 +07:00
parent 4a8e802c03
commit 45bec16c7f
7 changed files with 266 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Filters;
class QueryFilter
{
protected $builder;
protected $request;
public function __construct($builder, $request)
{
$this->builder = $builder;
$this->request = $request;
}
public function apply()
{
foreach ($this->filters() as $filter => $value) {
if (method_exists($this, $filter)) {
if (!$value) {
continue;
}
$this->$filter($value);
}
}
return $this->builder;
}
protected function filters()
{
return $this->request->all();
}
}