mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-22 04:16:05 +02:00
34 lines
674 B
PHP
34 lines
674 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Criteria\Sort;
|
|
|
|
use App\GraphQL\Schema\Fields\Base\CreatedAtField;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class RandomSortCriteria extends SortCriteria
|
|
{
|
|
public function __construct()
|
|
{
|
|
// Random Sort doesn't need a field so we fake it.
|
|
parent::__construct(new CreatedAtField);
|
|
}
|
|
|
|
/**
|
|
* Build the enum case.
|
|
*/
|
|
public function __toString(): string
|
|
{
|
|
return 'RANDOM';
|
|
}
|
|
|
|
/**
|
|
* Apply the ordering to the current Eloquent builder.
|
|
*/
|
|
public function sort(Builder $builder): Builder
|
|
{
|
|
return $builder->inRandomOrder();
|
|
}
|
|
}
|