Migrate backend to Porto architecture and fix minor bugs

- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
This commit is contained in:
F4ilji
2025-05-12 08:47:43 +05:00
parent 76deaf75f3
commit c01016a154
620 changed files with 16218 additions and 6073 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Ship\Builders;
use RuntimeException;
class FilterBuilder
{
protected array $filters = [];
/**
* Добавляет фильтр
*
* @param string $key Уникальный ключ фильтра (например 'category_filter')
* @param string $type Тип фильтра ('category', 'tag', 'search', 'sort')
* @param mixed $value Значение фильтра
* @param string $param Параметр из URL (например 'category')
* @param array|object|null $content Контент (например данные о категории)
* @return $this
*/
public function add(string $key, string $type, mixed $value, string $param, mixed $content = null): self
{
if (isset($this->filters[$key])) {
throw new RuntimeException("Фильтр с ключом '$key' уже существует.");
}
$this->filters[$key] = [
'type' => $type,
'value' => $value,
'param' => $param,
'content' => $content,
];
return $this;
}
/**
* Возвращает собранные фильтры
*
* @return array
*/
public function get(): array
{
return $this->filters;
}
public function reset(): self
{
$this->filters = [];
return $this;
}
}