first commit
This commit is contained in:
10
laravel/app/Contracts/FilterFactoryInterface.php
Normal file
10
laravel/app/Contracts/FilterFactoryInterface.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface FilterFactoryInterface
|
||||
{
|
||||
public function make(string $name, array $values): FilterInterface;
|
||||
}
|
||||
13
laravel/app/Contracts/FilterInterface.php
Normal file
13
laravel/app/Contracts/FilterInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
|
||||
interface FilterInterface
|
||||
{
|
||||
public function __invoke(Builder $builder, Closure $next): Builder;
|
||||
}
|
||||
18
laravel/app/Contracts/QueryFilterPipelineInterface.php
Normal file
18
laravel/app/Contracts/QueryFilterPipelineInterface.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Throwable;
|
||||
|
||||
interface QueryFilterPipelineInterface
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function applyFilters(Builder $builder, RequestFilterInterface $filterRequest): LengthAwarePaginator;
|
||||
|
||||
}
|
||||
26
laravel/app/Contracts/RequestFilterInterface.php
Normal file
26
laravel/app/Contracts/RequestFilterInterface.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface RequestFilterInterface
|
||||
{
|
||||
/**
|
||||
* Возвращает список фильтруемых полей
|
||||
* @return array<string>
|
||||
*/
|
||||
public function filters(): array;
|
||||
|
||||
/**
|
||||
* Возвращает значения фильтров
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function values(): array;
|
||||
|
||||
/**
|
||||
* Пагинация
|
||||
* @return int|null если null, без пагинации
|
||||
*/
|
||||
public function perPage(): ?int;
|
||||
}
|
||||
31
laravel/app/Contracts/TaskServiceInterface.php
Normal file
31
laravel/app/Contracts/TaskServiceInterface.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Throwable;
|
||||
|
||||
interface TaskServiceInterface
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function list(RequestFilterInterface $filters): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(array $data): Task;
|
||||
|
||||
public function show(Task $task): Task;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Task $task, array $data): Task;
|
||||
|
||||
public function delete(Task $task): void;
|
||||
}
|
||||
Reference in New Issue
Block a user