taktik - laravel
This commit is contained in:
42
app/Services/QueryRequestModifiers/Post/PostOrderDTO.php
Normal file
42
app/Services/QueryRequestModifiers/Post/PostOrderDTO.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\QueryRequestModifiers\Post;
|
||||
|
||||
use App\Services\CacheKeyInterface;
|
||||
use App\Services\QueryRequestModifiers\SortDirection;
|
||||
use App\Services\QueryRequestModifiers\OrderableDTO;
|
||||
|
||||
/**
|
||||
* @implements OrderableDTO<PostOrderDTO>
|
||||
*/
|
||||
readonly class PostOrderDTO implements CacheKeyInterface, OrderableDTO
|
||||
{
|
||||
public function __construct(public string $column, public SortDirection $direction)
|
||||
{
|
||||
}
|
||||
|
||||
public function toCacheKey(): string
|
||||
{
|
||||
return $this->column . '|' . $this->direction->value;
|
||||
}
|
||||
|
||||
public function getColumn(): string
|
||||
{
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
public function getDirection(): SortDirection
|
||||
{
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
public static function createFromValues(string $column, SortDirection $sortDirection): OrderableDTO
|
||||
{
|
||||
return new self(
|
||||
$column,
|
||||
$sortDirection
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user