mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 09:34:50 +02:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fec8c51dda | |||
| 5dcad93fab | |||
| b19185da8f | |||
| f036cd2d1b | |||
| 19b340bf75 | |||
| 73c2400a0f | |||
| 5476445ccc | |||
| 6a81ddd1ee | |||
| 624b076f03 | |||
| 25389ce3d2 | |||
| af2bc6c2dc | |||
| 7182fa39bd | |||
| fa27b2dd80 | |||
| 519fc09ef4 | |||
| 65a723f9b5 | |||
| e0ea789eeb | |||
| 654f8a7f70 | |||
| d399933cf0 | |||
| fd2ef1611b | |||
| a3f1a8c7e3 | |||
| f5e098875f | |||
| 333a519611 | |||
| effdcecd79 | |||
| ddceceda58 | |||
| 44d1145f4a | |||
| 0e41771f4c | |||
| 71c4f56a9d | |||
| 74d3ee200a | |||
| 9613657962 | |||
| d813ca3b66 | |||
| c30ad3e28f | |||
| 94bcdf1275 | |||
| 14b55970fe | |||
| 7fff5465c9 |
+18
-17
@@ -1,6 +1,6 @@
|
||||
# api
|
||||
API_PATH=/api
|
||||
API_URL=
|
||||
API_PATH=
|
||||
API_URL=http://api.animethemes.test
|
||||
|
||||
# app
|
||||
APP_NAME=AnimeThemes
|
||||
@@ -9,9 +9,10 @@ APP_DEBUG=true
|
||||
DEBUGBAR_ENABLED=true
|
||||
DEBUGBAR_EDITOR=
|
||||
AUDITING_ENABLED=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL=http://animethemes.test
|
||||
ASSET_URL=null
|
||||
APP_KEY=
|
||||
APP_LOCAL_IPS=
|
||||
|
||||
# audio
|
||||
AUDIO_DISK_DEFAULT=audios_local
|
||||
@@ -84,7 +85,7 @@ REDIS_CACHE_DB=1
|
||||
# dump
|
||||
DUMP_DISK=dumps_local
|
||||
DUMP_DISK_ROOT=
|
||||
DUMP_URL=http://localhost
|
||||
DUMP_URL="${APP_URL}"
|
||||
DUMP_PATH=/dump
|
||||
|
||||
# external profile
|
||||
@@ -95,10 +96,8 @@ FFMPEG_BINARIES=
|
||||
FFPROBE_BINARIES=
|
||||
|
||||
# filament
|
||||
FILAMENT_URL=
|
||||
FILAMENT_PATH=admin
|
||||
FILAMENT_SUBMISSION_URL=
|
||||
FILAMENT_SUBMISSION_PATH=submission
|
||||
FILAMENT_URL=http://admin.animethemes.test
|
||||
FILAMENT_PATH=
|
||||
|
||||
# filesystems
|
||||
FILESYSTEM_DISK=local
|
||||
@@ -168,12 +167,14 @@ SCRIPT_DISABLE_ASSERTS=
|
||||
SCRIPT_VISIBILITY=
|
||||
|
||||
# fortify
|
||||
FORTIFY_HOME=http://localhost
|
||||
FORTIFY_HOME="${APP_URL}"
|
||||
FORTIFY_PATH=
|
||||
FORTIFY_URL=http://localhost
|
||||
FORTIFY_URL="${APP_URL}"
|
||||
|
||||
# graphql
|
||||
GRAPHQL_URL=
|
||||
GRAPHIQL_URL="${GRAPHQL_URL}/graphiql"
|
||||
GRAPHIQL_GRAPHQL_ENDPOINT="${GRAPHQL_URL}"
|
||||
GRAPHQL_URL=http://graphql.animethemes.test
|
||||
GRAPHQL_PATH=/graphql
|
||||
GRAPHIQL_ENABLED=true
|
||||
|
||||
@@ -288,21 +289,21 @@ VIDEO_DISK_DEFAULT=videos_local
|
||||
VIDEO_DISKS=videos_local
|
||||
VIDEO_DISK_ROOT=
|
||||
VIDEO_PATH=/video
|
||||
VIDEO_URL=
|
||||
VIDEO_URL="${APP_URL}"
|
||||
VIDEO_RATE_LIMITER=90
|
||||
VIDEO_STREAMING_METHOD=response
|
||||
VIDEO_NGINX_REDIRECT=
|
||||
|
||||
SCRIPT_DISK=scripts_local
|
||||
SCRIPT_DISK_ROOT=
|
||||
SCRIPT_URL=
|
||||
SCRIPT_URL="${APP_URL}"
|
||||
SCRIPT_PATH=/videoscript
|
||||
|
||||
# web
|
||||
WEB_URL=http://localhost
|
||||
WEB_URL="${APP_URL}:3000"
|
||||
WEB_PATH=
|
||||
|
||||
# wiki
|
||||
WIKI_LOGIN=http://localhost/login
|
||||
WIKI_RESET_PASSWORD=http://localhost/reset-password
|
||||
WIKI_EXTERNAL_PROFILE=http://localhost/external
|
||||
WIKI_LOGIN="h${APP_URL}:3000/login"
|
||||
WIKI_RESET_PASSWORD="${APP_URL}:3000/reset-password"
|
||||
WIKI_EXTERNAL_PROFILE="${APP_URL}:3000/external"
|
||||
|
||||
+20
-19
@@ -1,6 +1,6 @@
|
||||
# api
|
||||
API_PATH=/api
|
||||
API_URL=
|
||||
API_PATH=
|
||||
API_URL=http://api.animethemes.test
|
||||
|
||||
# app
|
||||
APP_NAME=AnimeThemes
|
||||
@@ -9,9 +9,10 @@ APP_DEBUG=true
|
||||
DEBUGBAR_ENABLED=true
|
||||
DEBUGBAR_EDITOR=
|
||||
AUDITING_ENABLED=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL=http://animethemes.test
|
||||
ASSET_URL=null
|
||||
APP_KEY=
|
||||
APP_LOCAL_IPS=
|
||||
|
||||
# audio
|
||||
AUDIO_DISK_DEFAULT=audios_local
|
||||
@@ -85,7 +86,7 @@ REDIS_CACHE_DB=1
|
||||
# dump
|
||||
DUMP_DISK=dumps
|
||||
DUMP_DISK_ROOT=
|
||||
DUMP_URL=http://localhost
|
||||
DUMP_URL="${APP_URL}"
|
||||
DUMP_PATH=/dump
|
||||
|
||||
# ffmpeg
|
||||
@@ -93,10 +94,8 @@ FFMPEG_BINARIES=
|
||||
FFPROBE_BINARIES=
|
||||
|
||||
# filament
|
||||
FILAMENT_URL=
|
||||
FILAMENT_PATH=admin
|
||||
FILAMENT_SUBMISSION_URL=
|
||||
FILAMENT_SUBMISSION_PATH=submission
|
||||
FILAMENT_URL=http://admin.animethemes.test
|
||||
FILAMENT_PATH=
|
||||
|
||||
# filesystems
|
||||
FILESYSTEM_DISK=local
|
||||
@@ -166,12 +165,14 @@ SCRIPT_DISABLE_ASSERTS=
|
||||
SCRIPT_VISIBILITY=
|
||||
|
||||
# fortify
|
||||
FORTIFY_HOME=http://localhost:3000
|
||||
FORTIFY_HOME="${APP_URL}":3000
|
||||
FORTIFY_PATH=
|
||||
FORTIFY_URL=http://localhost
|
||||
FORTIFY_URL="${APP_URL}"
|
||||
|
||||
# graphql
|
||||
GRAPHQL_URL=
|
||||
GRAPHIQL_URL="${GRAPHQL_URL}/graphiql"
|
||||
GRAPHIQL_GRAPHQL_ENDPOINT="${GRAPHQL_URL}"
|
||||
GRAPHQL_URL=http://graphql.animethemes.test
|
||||
GRAPHQL_PATH=/graphql
|
||||
GRAPHIQL_ENABLED=true
|
||||
|
||||
@@ -223,7 +224,7 @@ QUEUE_FAILED_DRIVER=database-uuids
|
||||
SANCTUM_STATEFUL_DOMAINS=*
|
||||
|
||||
# scout
|
||||
SCOUT_DRIVER=elastic
|
||||
SCOUT_DRIVER=typesense
|
||||
SCOUT_PREFIX=
|
||||
SCOUT_QUEUE=false
|
||||
SCOUT_IDENTIFY=false
|
||||
@@ -236,7 +237,7 @@ ELASTIC_HOST=http://elasticsearch:9200
|
||||
ELASTIC_SCOUT_DRIVER_REFRESH_DOCUMENTS=false
|
||||
ELASTIC_MIGRATIONS_TABLE=elastic_migrations
|
||||
|
||||
TYPESENSE_HOST=localhost
|
||||
TYPESENSE_HOST=typesense
|
||||
TYPESENSE_PORT=8108
|
||||
TYPESENSE_PROTOCOL=http
|
||||
TYPESENSE_API_KEY=
|
||||
@@ -286,21 +287,21 @@ VIDEO_DISK_DEFAULT=videos_local
|
||||
VIDEO_DISKS=videos_local
|
||||
VIDEO_DISK_ROOT=
|
||||
VIDEO_PATH=/video
|
||||
VIDEO_URL=
|
||||
VIDEO_URL="${APP_URL}"
|
||||
VIDEO_RATE_LIMITER=90
|
||||
VIDEO_STREAMING_METHOD=response
|
||||
VIDEO_NGINX_REDIRECT=
|
||||
|
||||
SCRIPT_DISK=scripts_local
|
||||
SCRIPT_DISK_ROOT=
|
||||
SCRIPT_URL=
|
||||
SCRIPT_URL="${APP_URL}"
|
||||
SCRIPT_PATH=/videoscript
|
||||
|
||||
# web
|
||||
WEB_URL=http://localhost
|
||||
WEB_URL="${APP_URL}:3000"
|
||||
WEB_PATH=
|
||||
|
||||
# wiki
|
||||
WIKI_LOGIN=http://localhost/login
|
||||
WIKI_RESET_PASSWORD=http://localhost/reset-password
|
||||
WIKI_EXTERNAL_PROFILE=http://localhost/external
|
||||
WIKI_LOGIN="${APP_URL}:3000/login"
|
||||
WIKI_RESET_PASSWORD="${APP_URL}:3000/reset-password"
|
||||
WIKI_EXTERNAL_PROFILE="${APP_URL}:3000/external"
|
||||
@@ -0,0 +1,25 @@
|
||||
name: GraphQL Schema
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
graphql:
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.5'
|
||||
tools: dom, curl, libxml, mbstring, zip, pcntl, pdo
|
||||
- uses: actions/checkout@v3
|
||||
- name: Copy .env
|
||||
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
- name: Directory Permissions
|
||||
run: chmod -R 777 storage bootstrap/cache
|
||||
- name: Validate GraphQL Schema via Lighthouse
|
||||
run: |
|
||||
php artisan lighthouse:validate-schema
|
||||
@@ -1,6 +1,7 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/AnimeThemes/animethemes-server/actions/workflows/test.yml"><img src="https://github.com/AnimeThemes/animethemes-server/actions/workflows/test.yml/badge.svg?branch=main" alt="tests"></a>
|
||||
<a href="https://github.com/AnimeThemes/animethemes-server/actions/workflows/static-analysis.yml"><img src="https://github.com/AnimeThemes/animethemes-server/actions/workflows/static-analysis.yml/badge.svg?branch=main" alt="static-analysis"></a>
|
||||
<a href="https://github.com/AnimeThemes/animethemes-server/actions/workflows/graphql.yml"><img src="https://github.com/AnimeThemes/animethemes-server/actions/workflows/graphql.yml/badge.svg?branch=main" alt="graphql"></a>
|
||||
<a href="https://github.styleci.io/repos/111264405?branch=main"><img src="https://github.styleci.io/repos/111264405/shield?branch=main" alt="StyleCI"></a>
|
||||
<a href="https://discordapp.com/invite/m9zbVyQ"><img src="https://img.shields.io/discord/354388306580078594.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2"></a>
|
||||
<a href="https://github.com/AnimeThemes/animethemes-server/blob/main/LICENSE"><img src="https://img.shields.io/github/license/AnimeThemes/animethemes-server"></a>
|
||||
@@ -20,7 +21,8 @@ This project is powered by [**Laravel**](https://laravel.com/), a PHP framework
|
||||
- [Pre Setup](#pre-setup)
|
||||
- [PHP](#php)
|
||||
- [Setup](#setup)
|
||||
- [Web Server](#web-server)
|
||||
- [Laravel Herd](#laravel-herd)
|
||||
- [Docker](#docker)
|
||||
- [Running](#running)
|
||||
- [Extra Configuration](#extra-configuration)
|
||||
- [Feature Flags](#feature-flags)
|
||||
@@ -32,29 +34,19 @@ This project is powered by [**Laravel**](https://laravel.com/), a PHP framework
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* [Laravel Herd](https://herd.laravel.com/) or a webserver such as [Apache](https://httpd.apache.org/download.cgi) or
|
||||
[Nginx](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/)
|
||||
* PHP 8.5
|
||||
* MySQL 8+
|
||||
* [composer](https://getcomposer.org/download/) for vendor dependencies
|
||||
* [Laravel Herd](https://herd.laravel.com/) or [Docker](https://www.docker.com/)
|
||||
* MySQL 8+ or Docker
|
||||
* [composer](https://getcomposer.org/download/) or Docker
|
||||
|
||||
A LAMP stack, such as [XAMPP](https://www.apachefriends.org/download.html), can
|
||||
also be used to set up Apache, MySQL, and PHP.
|
||||
Docker will setup PHP, MySQL and Typesense for you. If you are on Windows, use the [WSL](https://learn.microsoft.com/windows/wsl/install) terminal.
|
||||
|
||||
Alternatively, you may use [Laravel Herd](https://herd.laravel.com), which
|
||||
provides a simple local development environment with PHP and a web server.
|
||||
Laravel Herd will setup PHP 8.5 for you. You should download and setup MySQL and Typesense manually.
|
||||
|
||||
## Pre Setup
|
||||
|
||||
### PHP
|
||||
|
||||
We should ensure that we have the following extensions enabled for php in `php.ini`.
|
||||
|
||||
`fileinfo` - Needed to detect MIME type of files during seeding.
|
||||
|
||||
`gd` - Needed to fake image files for testing.
|
||||
|
||||
`pdo_mysql` - Needed to use MySQL.
|
||||
You can skip this if you are using Docker.
|
||||
|
||||
In order to accept video uploads, we should ensure that php will accept requests of adequate sizes.
|
||||
|
||||
@@ -64,6 +56,8 @@ Set `upload_max_filesize` to `200M`.
|
||||
|
||||
## Setup
|
||||
|
||||
### Laravel Herd
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone git@github.com:AnimeThemes/animethemes-server.git
|
||||
@@ -72,24 +66,72 @@ cd animethemes-server
|
||||
# Create the database
|
||||
mysql -h localhost -u root -p -e "CREATE DATABASE IF NOT EXISTS ``animethemes`` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||
|
||||
# Install dependencies, migrate the database, run seeders and import dumps
|
||||
# Install dependencies, import dumps, migrate the database and run seeders
|
||||
composer setup
|
||||
|
||||
# Generate an application key
|
||||
php artisan key:generate
|
||||
|
||||
# Run the following in the project directory:
|
||||
herd link admin.animethemes.test
|
||||
herd link animethemes.test
|
||||
herd link api.animethemes.test
|
||||
herd link graphql.animethemes.test
|
||||
```
|
||||
|
||||
### Web Server
|
||||
### Docker
|
||||
|
||||
#### Laravel Herd
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone git@github.com:AnimeThemes/animethemes-server.git
|
||||
cd animethemes-server
|
||||
|
||||
```sh
|
||||
# Run the following in the project directory:
|
||||
herd link animethemes.test
|
||||
cp .env.example-sail .env
|
||||
|
||||
# Install Composer dependencies using a throwaway container
|
||||
docker run --rm \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
-v "$(pwd):/var/www/html" \
|
||||
-w /var/www/html \
|
||||
laravelsail/php82-composer:latest \
|
||||
composer install --ignore-platform-reqs
|
||||
|
||||
# Start sail
|
||||
./vendor/bin/sail up -d
|
||||
|
||||
# Generate an application key
|
||||
./vendor/bin/sail artisan key:generate
|
||||
|
||||
# Import dumps, migrate the database and run seeders
|
||||
./vendor/bin/sail artisan db:sync --drop
|
||||
```
|
||||
|
||||
You can optionally configure a shell alias following the [official Sail guide](https://laravel.com/docs/13.x/sail#configuring-a-shell-alias).
|
||||
The following instruction assume you have configured a shell alias. If not you need to replace `sail` with `./vendor/bin/sail`.
|
||||
|
||||
Open the following file and paste the contents there:
|
||||
|
||||
For Windows/WSL: `C:\Windows\System32\drivers\etc\hosts`
|
||||
|
||||
For Linux: `/etc/hosts`
|
||||
|
||||
```
|
||||
127.0.0.1 admin.animethemes.test
|
||||
127.0.0.1 animethemes.test
|
||||
127.0.0.1 api.animethemes.test
|
||||
127.0.0.1 graphql.animethemes.test
|
||||
```
|
||||
|
||||
Restart the container:
|
||||
|
||||
```bash
|
||||
sail restart
|
||||
sail artisan optimize
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
After installation, restart the web server to apply the configuration.
|
||||
|
||||
If all went well, AnimeThemes should be live at `http://animethemes.test` (or whatever set the server name is set to).
|
||||
If all went well, AnimeThemes should be live at `http://animethemes.test`.
|
||||
|
||||
## Extra Configuration
|
||||
|
||||
@@ -104,6 +146,8 @@ For example, if we want to enable video streams, we need to set the `App\Feature
|
||||
```sh
|
||||
# Open the terminal of tinker
|
||||
php artisan tinker
|
||||
# or through Docker
|
||||
sail artisan tinker
|
||||
|
||||
# Create the user
|
||||
$user = User::factory()->create(['name' => 'User Name', 'email' => 'example@example.com', 'password' => 'password', 'email_verified_at' => now()]);
|
||||
@@ -115,18 +159,15 @@ $user->assignRole('Admin');
|
||||
|
||||
### Search
|
||||
|
||||
If we want to enable scout, we need to configure a search engine (either Elasticsearch or Typesense).
|
||||
Change the `SCOUT_DRIVER` variable in `.env` to "typesense". Add additional configuration like host and port.
|
||||
|
||||
Change the `SCOUT_DRIVER` variable in `.env` to either "elastic" or "typesense". Add additional configuration like host and port.
|
||||
|
||||
Migrate and import models into our indices using:
|
||||
Import models into our indices using:
|
||||
|
||||
```sh
|
||||
# Elasticsearch: run the elastic migrations
|
||||
php artisan elastic:migrate
|
||||
|
||||
# Elasticsearch and Typesense: Import Models with a seeder
|
||||
php artisan db:seed --class="Database\Seeders\Scout\ImportModelsSeeder"
|
||||
# Import Models using a custom artisan command
|
||||
php artisan scout:import-all
|
||||
# or through Docker
|
||||
sail artisan scout:import-all
|
||||
```
|
||||
|
||||
### Local Storage
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\Discord;
|
||||
|
||||
use App\Actions\ActionResult;
|
||||
use App\Enums\Actions\ActionStatus;
|
||||
use App\Models\Discord\DiscordThread;
|
||||
use App\Models\Wiki\Anime;
|
||||
use Exception;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DiscordThreadAction
|
||||
{
|
||||
/**
|
||||
* Get the HTTP client for Discord API.
|
||||
*/
|
||||
public static function getHttp(): PendingRequest
|
||||
{
|
||||
return Http::withHeaders(['x-api-key' => Config::get('services.discord.api_key')])
|
||||
->baseUrl(Config::get('services.discord.api_url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $fields
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(Anime $anime, array $fields): ActionResult
|
||||
{
|
||||
try {
|
||||
$response = static::getHttp()
|
||||
->acceptJson()
|
||||
->post('/thread', ['name' => Arr::get($fields, 'name'), 'slug' => $anime->slug])
|
||||
->throw()
|
||||
->json();
|
||||
|
||||
if (Arr::has($response, 'id')) {
|
||||
DiscordThread::query()->create([
|
||||
DiscordThread::ATTRIBUTE_NAME => Arr::get($response, 'name'),
|
||||
DiscordThread::ATTRIBUTE_ID => intval(Arr::get($response, 'id')),
|
||||
DiscordThread::ATTRIBUTE_ANIME => $anime->getKey(),
|
||||
]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return new ActionResult(ActionStatus::PASSED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thread by ID.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function get(string $id): array
|
||||
{
|
||||
return static::getHttp()
|
||||
->acceptJson()
|
||||
->get('/thread', ['id' => $id])
|
||||
->throw()
|
||||
->json();
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,23 @@ use App\Actions\ActionResult;
|
||||
use App\Enums\Actions\ActionStatus;
|
||||
use App\Enums\Actions\Models\Wiki\Video\DiscordNotificationType;
|
||||
use App\Models\Wiki\Video;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class DiscordVideoNotificationAction
|
||||
{
|
||||
/**
|
||||
* Get the HTTP client for Discord API.
|
||||
*/
|
||||
public static function getHttp(): PendingRequest
|
||||
{
|
||||
return Http::withHeaders(['x-api-key' => Config::get('services.discord.api_key')])
|
||||
->baseUrl(Config::get('services.discord.api_url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, Video> $videos
|
||||
* @param array<string, mixed> $fields
|
||||
@@ -22,37 +33,10 @@ class DiscordVideoNotificationAction
|
||||
{
|
||||
$type = Arr::get($fields, DiscordNotificationType::getFieldKey());
|
||||
|
||||
$newVideos = [];
|
||||
|
||||
foreach ($videos as $video) {
|
||||
$video
|
||||
->load([
|
||||
'animethemeentries.animetheme.anime.discordthread',
|
||||
]);
|
||||
|
||||
$anime = $video->animethemeentries->first()->animetheme->anime;
|
||||
|
||||
if ($anime->discordthread === null) {
|
||||
if (Str::length($anime->name) >= 100) {
|
||||
$anime->name = Str::limit($anime->name, 96, '...');
|
||||
}
|
||||
|
||||
$threadAction = new DiscordThreadAction();
|
||||
|
||||
$threadAction->handle($anime, ['name' => $anime->getName()]);
|
||||
$anime->load('discordthread');
|
||||
}
|
||||
|
||||
$newVideos[] = [
|
||||
'threadId' => $anime->discordthread->getKey(),
|
||||
'videoId' => $video->getKey(),
|
||||
];
|
||||
}
|
||||
|
||||
DiscordThreadAction::getHttp()
|
||||
static::getHttp()
|
||||
->post('/notification', [
|
||||
'type' => $type->value,
|
||||
'videos' => $newVideos,
|
||||
'videos' => $videos->map(fn (Video $video): array => ['videoId' => $video->getKey()])->toArray(),
|
||||
])
|
||||
->throw();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
||||
*/
|
||||
public function update(User $user, array $input): void
|
||||
{
|
||||
/** @var array{name: string, email: string} $validated */
|
||||
$validated = Validator::make($input, [
|
||||
User::ATTRIBUTE_NAME => ['required_without:'.User::ATTRIBUTE_EMAIL, 'string', 'max:35', 'alpha_dash', Rule::unique(User::class)->ignore($user->id), new ModerationRule()],
|
||||
User::ATTRIBUTE_EMAIL => ['required_without:'.User::ATTRIBUTE_NAME, 'string', 'email', 'max:255', 'indisposable', Rule::unique(User::class)->ignore($user->id)],
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\GraphQL;
|
||||
|
||||
use App\Concerns\Actions\GraphQL\ConstrainsEagerLoads;
|
||||
use App\Concerns\Actions\GraphQL\FieldSelection;
|
||||
use App\Concerns\Actions\GraphQL\PaginatesModels;
|
||||
use App\Concerns\Actions\GraphQL\SortsModels;
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\GraphQL\Argument\SortArgument;
|
||||
use App\GraphQL\Criteria\Sort\RelationSortCriteria;
|
||||
use App\GraphQL\Schema\Types\BaseType;
|
||||
use App\Rules\GraphQL\Argument\FirstArgumentRule;
|
||||
use App\Scout\Criteria;
|
||||
use App\Scout\Search;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use Illuminate\Contracts\Pagination\Paginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use UnitEnum;
|
||||
|
||||
class IndexAction
|
||||
{
|
||||
use ConstrainsEagerLoads;
|
||||
use FieldSelection;
|
||||
use PaginatesModels;
|
||||
use SortsModels;
|
||||
|
||||
public function index(Builder $builder, array $args, BaseType $type, ResolveInfo $resolveInfo): Paginator
|
||||
{
|
||||
$this->withAggregates($builder, $args, $this->getSelection($resolveInfo), $type);
|
||||
|
||||
$this->filter($builder, $args, $type);
|
||||
|
||||
$this->sort($builder, $args);
|
||||
|
||||
$this->constrainEagerLoads($builder, $resolveInfo, $type);
|
||||
|
||||
return $this->paginate($builder, $args);
|
||||
}
|
||||
|
||||
public function search(Builder $builder, array $args, BaseType $type, ResolveInfo $resolveInfo): Paginator
|
||||
{
|
||||
$criteria = new Criteria(Arr::get($args, 'search'));
|
||||
|
||||
$searchBuilder = Search::getSearch($builder->getModel(), $criteria);
|
||||
|
||||
$eloquentCallback = function (Builder $builder) use ($args, $type, $resolveInfo): void {
|
||||
$this->withAggregates($builder, $args, $this->getSelection($resolveInfo), $type);
|
||||
|
||||
$this->filter($builder, $args, $type);
|
||||
|
||||
$this->sort($builder, $args);
|
||||
|
||||
$this->constrainEagerLoads($builder, $resolveInfo, $type);
|
||||
};
|
||||
|
||||
// Note: First for searching must not be too high.
|
||||
$first = min(100, Arr::get($args, 'first'));
|
||||
$page = Arr::get($args, 'page', 1);
|
||||
|
||||
Validator::make(['first' => $first], [
|
||||
'first' => ['required', 'integer', 'min:1', new FirstArgumentRule()],
|
||||
])->validate();
|
||||
|
||||
/** @var array<int, UnitEnum&EnumSort> $sorts */
|
||||
$sorts = Arr::get($args, SortArgument::ARGUMENT, []);
|
||||
|
||||
$sortsRaw = [];
|
||||
foreach ($sorts as $sort) {
|
||||
$criterion = $sort->getSortCriteria();
|
||||
|
||||
$column = $criterion->getColumn();
|
||||
$direction = $criterion->getDirection();
|
||||
$isString = $criterion->isStringField();
|
||||
|
||||
if ($criterion instanceof RelationSortCriteria) {
|
||||
$sortsRaw[$column] = [
|
||||
'direction' => $direction->value,
|
||||
'isString' => $isString,
|
||||
'relation' => $criterion->getRelation(),
|
||||
];
|
||||
} else {
|
||||
$sortsRaw[$column] = [
|
||||
'direction' => $direction,
|
||||
'isString' => $isString,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $searchBuilder->search($eloquentCallback, $first, $page, $sortsRaw);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\GraphQL;
|
||||
|
||||
use App\Concerns\Actions\GraphQL\ConstrainsEagerLoads;
|
||||
use App\Concerns\Actions\GraphQL\FiltersModels;
|
||||
use App\GraphQL\Schema\Types\BaseType;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShowAction
|
||||
{
|
||||
use ConstrainsEagerLoads;
|
||||
use FiltersModels;
|
||||
|
||||
public function show(Builder $builder, array $args, BaseType $type, ResolveInfo $resolveInfo): Model
|
||||
{
|
||||
$this->withAggregates($builder, $args, $this->getSelection($resolveInfo), $type);
|
||||
|
||||
$this->filter($builder, $args, $type);
|
||||
|
||||
$this->constrainEagerLoads($builder, $resolveInfo, $type);
|
||||
|
||||
return $builder->firstOrFail();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\Models\Wiki\Anime;
|
||||
|
||||
use App\Actions\ActionResult;
|
||||
use App\Enums\Actions\ActionStatus;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class AnimeDateAction
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, Anime> $anime
|
||||
*/
|
||||
public function handle(Collection $anime): ActionResult
|
||||
{
|
||||
$anilistIds = $anime
|
||||
->map(fn (Anime $anime) => $anime->resources->where(ExternalResource::ATTRIBUTE_SITE, ResourceSite::ANILIST->value)->first()?->external_id)
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$query = <<<'GRAPHQL'
|
||||
query AnimeDates($ids: [Int]) {
|
||||
Page(perPage: 20) {
|
||||
media(id_in: $ids, type: ANIME) {
|
||||
id
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
endDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GRAPHQL;
|
||||
|
||||
$response = Http::post('https://graphql.anilist.co', [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
'ids' => $anilistIds,
|
||||
],
|
||||
])
|
||||
->throw();
|
||||
|
||||
if (! $response->ok() || $response->json('errors')) {
|
||||
return new ActionResult(ActionStatus::FAILED, $response->json('errors.0.message'));
|
||||
}
|
||||
|
||||
foreach ($response->json('data.Page.media') as $media) {
|
||||
$animeToUpdate = $anime->first(
|
||||
fn (Anime $anime): bool => $anime->resources->where(ExternalResource::ATTRIBUTE_SITE, ResourceSite::ANILIST->value)->first()?->external_id === Arr::integer($media, 'id')
|
||||
);
|
||||
|
||||
$animeToUpdate?->update([
|
||||
'start_date' => Arr::get($media, 'startDate'),
|
||||
'end_date' => Arr::get($media, 'endDate'),
|
||||
]);
|
||||
}
|
||||
|
||||
return new ActionResult(ActionStatus::PASSED);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ use App\Actions\Models\Wiki\ExternalApiAction;
|
||||
use App\Contracts\Actions\Models\Wiki\BackfillImages;
|
||||
use App\Contracts\Actions\Models\Wiki\BackfillResources;
|
||||
use App\Contracts\Actions\Models\Wiki\BackfillSynonyms;
|
||||
use App\Enums\Models\Wiki\AnimeSynonymType;
|
||||
use App\Enums\Models\Wiki\ImageFacet;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Enums\Models\Wiki\SynonymType;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -145,9 +145,9 @@ class AnilistAnimeExternalApiAction extends ExternalApiAction implements Backfil
|
||||
public function getSynonymsMapping(): array
|
||||
{
|
||||
return [
|
||||
AnimeSynonymType::ENGLISH->value => 'data.Media.title.english',
|
||||
AnimeSynonymType::NATIVE->value => 'data.Media.title.native',
|
||||
AnimeSynonymType::OTHER->value => 'data.Media.title.romaji',
|
||||
SynonymType::ENGLISH->value => 'data.Media.title.english',
|
||||
SynonymType::NATIVE->value => 'data.Media.title.native',
|
||||
SynonymType::OTHER->value => 'data.Media.title.romaji',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +196,9 @@ class BackfillAudioAction extends BackfillAction
|
||||
|
||||
$orderByNameQuery = $sortRelation->getRelationExistenceQuery($sortRelation->getQuery(), $builder, [Anime::ATTRIBUTE_NAME]);
|
||||
$orderBySeasonQuery = $sortRelation->getRelationExistenceQuery($sortRelation->getQuery(), $builder, [Anime::ATTRIBUTE_SEASON]);
|
||||
$orderByYearQuery = $sortRelation->getRelationExistenceQuery($sortRelation->getQuery(), $builder, [Anime::ATTRIBUTE_YEAR]);
|
||||
$orderByMediaFormatQuery = $sortRelation->getRelationExistenceQuery($sortRelation->getQuery(), $builder, [Anime::ATTRIBUTE_FORMAT]);
|
||||
$orderByYearQuery = $sortRelation->getRelationExistenceQuery($sortRelation->getQuery(), $builder, [Anime::ATTRIBUTE_START_DATE]);
|
||||
|
||||
return $builder->whereHas(AnimeTheme::RELATION_VIDEOS, fn (Builder $relationBuilder) => $relationBuilder->whereKey($this->getModel()))
|
||||
->orderBy($orderByMediaFormatQuery->toBase())
|
||||
->orderBy($orderByYearQuery->toBase())
|
||||
->orderBy($orderBySeasonQuery->toBase())
|
||||
->orderBy($orderByNameQuery->toBase())
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Actions\Storage\Admin\Dump;
|
||||
|
||||
use App\Concerns\Repositories\Admin\ReconcilesDumpRepositories;
|
||||
use App\Models\Admin\ActionLog;
|
||||
use App\Models\Admin\Activity;
|
||||
use App\Models\Admin\Announcement;
|
||||
use App\Models\Admin\Dump;
|
||||
use App\Models\Admin\Feature;
|
||||
@@ -27,7 +27,8 @@ class DumpAdminAction extends DumpAction
|
||||
{
|
||||
return [
|
||||
'action_events', // Nova events
|
||||
ActionLog::TABLE,
|
||||
'action_logs',
|
||||
Activity::TABLE,
|
||||
Announcement::TABLE,
|
||||
Dump::TABLE,
|
||||
Feature::TABLE,
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace App\Actions\Storage\Admin\Dump;
|
||||
|
||||
use App\Concerns\Repositories\Admin\ReconcilesDumpRepositories;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\AnimeSynonym;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use App\Models\Wiki\Artist;
|
||||
@@ -46,19 +45,16 @@ class DumpContentAction extends DumpAction
|
||||
Anime::TABLE,
|
||||
AnimeSeries::TABLE,
|
||||
AnimeStudio::TABLE,
|
||||
AnimeSynonym::TABLE,
|
||||
AnimeTheme::TABLE,
|
||||
AnimeThemeEntry::TABLE,
|
||||
AnimeThemeEntryVideo::TABLE,
|
||||
Artist::TABLE,
|
||||
ArtistMember::TABLE,
|
||||
'artist_song',
|
||||
Audio::TABLE,
|
||||
ExternalResource::TABLE,
|
||||
Group::TABLE,
|
||||
Image::TABLE,
|
||||
Imageable::TABLE,
|
||||
'memberships',
|
||||
Performance::TABLE,
|
||||
Resourceable::TABLE,
|
||||
Series::TABLE,
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\Storage\Admin\Dump;
|
||||
|
||||
use App\Concerns\Repositories\Admin\ReconcilesDumpRepositories;
|
||||
use App\Models\Discord\DiscordThread;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DumpDiscordAction extends DumpAction
|
||||
{
|
||||
use ReconcilesDumpRepositories;
|
||||
|
||||
final public const string FILENAME_PREFIX = 'animethemes-db-dump-discord-';
|
||||
|
||||
/**
|
||||
* The list of tables to include in the dump.
|
||||
*/
|
||||
public static function allowedTables(): array
|
||||
{
|
||||
return [
|
||||
DiscordThread::TABLE,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The temporary path for the database dump.
|
||||
* Note: The dumper library does not support writing to disk, so we have to write to the local filesystem first.
|
||||
* Pattern: "animethemes-db-dump-discord-{milliseconds from epoch}.sql".
|
||||
*/
|
||||
protected function getDumpFile(): string
|
||||
{
|
||||
$filesystem = Storage::disk('local');
|
||||
|
||||
return Str::of($filesystem->path(''))
|
||||
->append(DumpDiscordAction::FILENAME_PREFIX)
|
||||
->append(strval(Date::now()->valueOf()))
|
||||
->append('.sql')
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,9 @@ class UploadVideoAction extends UploadAction
|
||||
|
||||
$this->uploadScript($video);
|
||||
|
||||
$this->addToPlaylist($video);
|
||||
if ($this->entry instanceof AnimeThemeEntry) {
|
||||
$this->addToPlaylist($video);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
@@ -165,7 +167,7 @@ class UploadVideoAction extends UploadAction
|
||||
}
|
||||
|
||||
new StoreTrackAction()->store($playlist, PlaylistTrack::query(), [
|
||||
PlaylistTrack::ATTRIBUTE_ENTRY => $video->animethemeentries->first()->getKey(),
|
||||
PlaylistTrack::ATTRIBUTE_ENTRY => $this->entry->getKey(),
|
||||
PlaylistTrack::ATTRIBUTE_VIDEO => $video->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Actions\Submission;
|
||||
|
||||
use App\Enums\Models\User\SubmissionComparisonAction;
|
||||
use App\Enums\Models\User\SubmissionStatus;
|
||||
use App\Filament\Resources\User\SubmissionResource;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\User\Submission;
|
||||
use App\Models\User\Submission\SubmissionAnime;
|
||||
use App\Models\User\Submission\SubmissionComparison;
|
||||
use App\Models\User\Submission\SubmissionSeries;
|
||||
use App\Models\User\Submission\SubmissionStudio;
|
||||
use App\Models\User\Submission\SubmissionSynonym;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use App\Models\Wiki\Series;
|
||||
use App\Models\Wiki\Studio;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SubmitNewAnimeAction
|
||||
{
|
||||
public function handle(User $user, array $data): void
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$submission = Submission::query()->create([
|
||||
Submission::ATTRIBUTE_SOURCE => Arr::get($data, Submission::ATTRIBUTE_SOURCE),
|
||||
Submission::ATTRIBUTE_STATUS => SubmissionStatus::PENDING,
|
||||
Submission::ATTRIBUTE_USER => $user->getKey(),
|
||||
]);
|
||||
|
||||
$anime = SubmissionAnime::query()->create(Arr::get($data, 'anime'));
|
||||
|
||||
$submission->submitted()->associate($anime);
|
||||
|
||||
$this->handleSynonyms($submission, $data);
|
||||
|
||||
// TODO: handle themes.
|
||||
|
||||
$this->handleRelation($submission, $data, SubmissionAnime::RELATION_SERIES, SubmissionSeries::class, Series::class);
|
||||
$this->handleRelation($submission, $data, SubmissionAnime::RELATION_RESOURCES, SubmissionResource::class, ExternalResource::class);
|
||||
$this->handleRelation($submission, $data, SubmissionAnime::RELATION_STUDIOS, SubmissionStudio::class, Studio::class);
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::error($e->getMessage());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleSynonyms(Submission $submission, array $data): void
|
||||
{
|
||||
foreach (Arr::get($data, SubmissionAnime::RELATION_SYNONYMS) as $synonym) {
|
||||
$submissionSynonym = SubmissionSynonym::query()->create($synonym);
|
||||
|
||||
$submissionSynonym->submission()->attach([
|
||||
$submission->getKey() => [
|
||||
SubmissionComparison::ATTRIBUTE_ACTION => SubmissionComparisonAction::CREATE,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleRelation(Submission $submission, array $data, string $relation, string $submissionModel, string $model): void
|
||||
{
|
||||
$list = Arr::get($data, $relation, []);
|
||||
|
||||
foreach ($list as $item) {
|
||||
$type = Arr::string($item, 'type');
|
||||
|
||||
if ($type === 'create') {
|
||||
SubmissionComparison::query()->create([
|
||||
SubmissionComparison::ATTRIBUTE_ACTION => SubmissionComparisonAction::CREATE,
|
||||
SubmissionComparison::ATTRIBUTE_SUBMISSION => $submission->getKey(),
|
||||
SubmissionComparison::ATTRIBUTE_SUBMITTED_TYPE => Relation::getMorphAlias($submissionModel),
|
||||
SubmissionComparison::ATTRIBUTE_SUBMITTED_ID => $submissionModel::query()->create($item['data'])->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($type === 'attach') {
|
||||
SubmissionComparison::query()->create([
|
||||
SubmissionComparison::ATTRIBUTE_ACTION => SubmissionComparisonAction::ATTACH,
|
||||
SubmissionComparison::ATTRIBUTE_SUBMISSION => $submission->getKey(),
|
||||
SubmissionComparison::ATTRIBUTE_ACTIONABLE_TYPE => Relation::getMorphAlias($model),
|
||||
SubmissionComparison::ATTRIBUTE_ACTIONABLE_ID => $item['data']['id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Casts;
|
||||
|
||||
use App\ValueObjects\FuzzyDate;
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class AsFuzzyDate implements CastsAttributes
|
||||
{
|
||||
public function get(Model $model, string $key, mixed $value, array $attributes): ?FuzzyDate
|
||||
{
|
||||
return FuzzyDate::fromString($value);
|
||||
}
|
||||
|
||||
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
|
||||
{
|
||||
if (blank($value) || $value === '00000000') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($value instanceof FuzzyDate) {
|
||||
return $value->toString();
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
return FuzzyDate::fromString($value)?->toString();
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
return new FuzzyDate(
|
||||
(int) Arr::get($value, 'year') ?: null,
|
||||
(int) Arr::get($value, 'month') ?: null,
|
||||
(int) Arr::get($value, 'day') ?: null,
|
||||
)->toString();
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('Invalid FuzzyDate value.');
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\GraphQL\Schema\Fields\Base\Aggregate\AggregateField;
|
||||
use App\GraphQL\Schema\Fields\Field;
|
||||
use App\GraphQL\Schema\Types\BaseType;
|
||||
use App\GraphQL\Schema\Unions\BaseUnion;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
trait AggregatesFields
|
||||
{
|
||||
public function withAggregates(Builder $builder, array $args, array $selection, BaseType|BaseUnion $type): Builder
|
||||
{
|
||||
if ($type instanceof BaseUnion) {
|
||||
return $builder;
|
||||
}
|
||||
|
||||
collect($type->fieldClasses())
|
||||
->filter(fn (Field $field): bool => $field instanceof AggregateField && $field->shouldAggregate($args, $selection, $type))
|
||||
->each(fn (AggregateField $selectedAggregate): Builder => $selectedAggregate->with($builder));
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function loadAggregates(Model $model, array $args, array $selection, BaseType|BaseUnion $type): Model
|
||||
{
|
||||
if ($type instanceof BaseUnion) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
collect($type->fieldClasses())
|
||||
->filter(fn (Field $field): bool => $field instanceof AggregateField && $field->shouldAggregate($args, $selection, $type))
|
||||
->each(fn (AggregateField $selectedAggregate): Model => $selectedAggregate->load($model));
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\GraphQL\Schema\Fields\Relations\BelongsToManyRelation;
|
||||
use App\GraphQL\Schema\Fields\Relations\Relation;
|
||||
use App\GraphQL\Schema\Types\BaseType;
|
||||
use App\GraphQL\Schema\Types\EdgeType;
|
||||
use App\GraphQL\Schema\Types\EloquentType;
|
||||
use App\GraphQL\Schema\Unions\BaseUnion;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation as EloquentRelation;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait ConstrainsEagerLoads
|
||||
{
|
||||
use AggregatesFields;
|
||||
use FieldSelection;
|
||||
use FiltersModels;
|
||||
use SortsModels;
|
||||
|
||||
/**
|
||||
* Apply eager loads with filters and sorting.
|
||||
*/
|
||||
protected function constrainEagerLoads(Builder $query, ResolveInfo $resolveInfo, BaseType $type, string $fieldName = 'data'): void
|
||||
{
|
||||
$this->processEagerLoadForType($query, $this->getSelection($resolveInfo, $fieldName), $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process recursively the relations available for the given type.
|
||||
*/
|
||||
private function processEagerLoadForType(Builder $builder, array $selection, BaseType|BaseUnion $type): void
|
||||
{
|
||||
$eagerLoadRelations = [];
|
||||
|
||||
/** @var array<int, Relation> $relations */
|
||||
$relations = collect($type->relations())
|
||||
->filter(fn (Relation $relation) => Arr::has($selection, $relation->name()))
|
||||
->all();
|
||||
|
||||
foreach ($relations as $relation) {
|
||||
$name = $relation->name();
|
||||
|
||||
$relationSelection = Arr::get($selection, "{$name}.{$name}");
|
||||
|
||||
$relationType = $relation->baseType();
|
||||
|
||||
$eagerLoadRelations[$relation->getRelationName()] = function (EloquentRelation $eloquentRelation) use ($relationSelection, $relationType, $relation): void {
|
||||
match (true) {
|
||||
$eloquentRelation instanceof MorphTo => $this->processMorphToRelation($relationSelection, $relationType, $eloquentRelation),
|
||||
$relationType instanceof BaseUnion => $this->processUnion($relationSelection, $relationType, $eloquentRelation),
|
||||
default => $this->processGenericRelation($relationSelection, $relationType, $eloquentRelation, $relation),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
$builder->with($eagerLoadRelations);
|
||||
}
|
||||
|
||||
/**
|
||||
* MorphTo relationships have to be handled differently since they can have multiple types.
|
||||
*/
|
||||
private function processMorphToRelation(array $selection, BaseUnion $union, MorphTo $relation): void
|
||||
{
|
||||
$unions = Arr::get($selection, 'unions');
|
||||
|
||||
/** @var array<int, EloquentType> $types */
|
||||
$types = collect($union->baseTypes())
|
||||
->filter(fn (BaseType $type): bool => $type instanceof EloquentType)
|
||||
->filter(fn (EloquentType $type) => Arr::has($unions, $type->name()))
|
||||
->all();
|
||||
|
||||
$morphConstrains = [];
|
||||
foreach ($types as $type) {
|
||||
$typeSelection = Arr::get($unions, "{$type->name()}.selectionSet", []);
|
||||
|
||||
$morphConstrains[$type->model()] = function (Builder $query) use ($typeSelection, $type): void {
|
||||
$this->processEagerLoadForType($query, $typeSelection, $type);
|
||||
};
|
||||
}
|
||||
|
||||
$relation->constrain($morphConstrains);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a union relation by applying the eager loads for each type in the union.
|
||||
*/
|
||||
private function processUnion(array $selection, BaseUnion $union, EloquentRelation $relation): void
|
||||
{
|
||||
$unions = Arr::get($selection, 'selectionSet.data.data.unions', []);
|
||||
|
||||
$types = collect($union->baseTypes())
|
||||
->filter(fn (BaseType $type) => Arr::has($unions, $type->name()))
|
||||
->all();
|
||||
|
||||
foreach ($types as $type) {
|
||||
$typeSelection = Arr::get($unions, "{$type->name()}.selectionSet", []);
|
||||
|
||||
$this->processEagerLoadForType($relation->getQuery(), $typeSelection, $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a generic relation by applying filters, sorting and eager loads.
|
||||
*/
|
||||
private function processGenericRelation(array $selection, BaseType $type, EloquentRelation $relation, Relation $graphqlRelation): void
|
||||
{
|
||||
$builder = $relation->getQuery();
|
||||
|
||||
$args = Arr::get($selection, 'args');
|
||||
|
||||
$this->withAggregates($builder, $args, Arr::get($selection, 'selectionSet'), $type);
|
||||
|
||||
$this->filter($builder, $args, $type);
|
||||
|
||||
$this->sort($builder, $args);
|
||||
|
||||
$fields = Arr::get($selection, 'selectionSet.data.data.selectionSet')
|
||||
?? Arr::get($selection, 'selectionSet.edges.edges.selectionSet.node.node.selectionSet')
|
||||
?? Arr::get($selection, 'selectionSet.nodes.nodes.selectionSet')
|
||||
?? Arr::get($selection, 'selectionSet', []);
|
||||
|
||||
$edgeSelection = Arr::get($selection, 'selectionSet.edges.edges.selectionSet');
|
||||
|
||||
if ($edgeSelection && $graphqlRelation instanceof BelongsToManyRelation) {
|
||||
$this->processPivotRelation($edgeSelection, $graphqlRelation->getEdgeType(), $relation);
|
||||
}
|
||||
|
||||
$this->processEagerLoadForType($builder, $fields, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a pivot relation for a pivot model.
|
||||
*/
|
||||
private function processPivotRelation(array $edgeSelection, EdgeType $edgeType, EloquentRelation $relation): void
|
||||
{
|
||||
if (! $relation instanceof BelongsToMany) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pivotRelations = collect($edgeType->relations())
|
||||
->filter(fn (Relation $rel) => Arr::has($edgeSelection, $rel->name()))
|
||||
->all();
|
||||
|
||||
foreach ($pivotRelations as $graphRelation) {
|
||||
$name = $graphRelation->name();
|
||||
$relationSelection = Arr::get($edgeSelection, "{$name}.{$name}");
|
||||
$relationType = $graphRelation->baseType();
|
||||
$eloquentName = $graphRelation->getRelationName();
|
||||
|
||||
$accessor = $relation->getPivotAccessor();
|
||||
|
||||
$relation->with("{$accessor}.{$eloquentName}", function (EloquentRelation $query) use ($relationSelection, $relationType, $graphRelation): void {
|
||||
$this->processGenericRelation($relationSelection, $relationType, $query, $graphRelation);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\GraphQL\ResolveInfo as GraphQLResolveInfo;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait FieldSelection
|
||||
{
|
||||
protected function getSelection(ResolveInfo $resolveInfo, string $fieldName = 'data'): array
|
||||
{
|
||||
$resolveInfo = new GraphQLResolveInfo($resolveInfo);
|
||||
|
||||
return Arr::get($resolveInfo->getFieldSelectionWithAliases(100), "{$fieldName}.{$fieldName}.selectionSet")
|
||||
?? $resolveInfo->getFieldSelectionWithAliases(100);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\GraphQL\Criteria\Filter\FilterCriteria;
|
||||
use App\GraphQL\Schema\Types\BaseType;
|
||||
use App\GraphQL\Schema\Unions\BaseUnion;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
trait FiltersModels
|
||||
{
|
||||
public function filter(Builder $builder, array $args, BaseType|BaseUnion $type): Builder
|
||||
{
|
||||
// union not supported yet
|
||||
if ($type instanceof BaseUnion) {
|
||||
return $builder;
|
||||
}
|
||||
|
||||
$criteria = FilterCriteria::parse($type, $args);
|
||||
|
||||
foreach ($criteria as $criterion) {
|
||||
$criterion->filter($builder);
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\Rules\GraphQL\Argument\FirstArgumentRule;
|
||||
use Illuminate\Contracts\Pagination\Paginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
trait PaginatesModels
|
||||
{
|
||||
public function paginate(Builder $builder, array $args): Paginator
|
||||
{
|
||||
$first = Arr::get($args, 'first');
|
||||
$page = Arr::get($args, 'page');
|
||||
|
||||
Validator::make(['first' => $first], [
|
||||
'first' => ['required', 'integer', 'min:1', new FirstArgumentRule()],
|
||||
])->validate();
|
||||
|
||||
return $builder->paginate($first, page: $page);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Actions\GraphQL;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\GraphQL\Argument\SortArgument;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait SortsModels
|
||||
{
|
||||
public function sort(Builder $builder, array $args): Builder
|
||||
{
|
||||
/** @var EnumSort[] $sorts */
|
||||
$sorts = Arr::get($args, SortArgument::ARGUMENT, []);
|
||||
|
||||
foreach ($sorts as $sort) {
|
||||
$sort->getSortCriteria()->sort($builder);
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Filament\ActionLogs;
|
||||
|
||||
use App\Models\Admin\ActionLog;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
trait HasActionLogs
|
||||
{
|
||||
protected string $batchId = '';
|
||||
protected ?ActionLog $actionLog = null;
|
||||
protected ?Model $recordLog = null;
|
||||
protected ?Model $parentRecordLog = null;
|
||||
protected ?Model $pivot = null;
|
||||
|
||||
public function createBatchId(): string
|
||||
{
|
||||
$this->batchId = Str::orderedUuid()->__toString();
|
||||
|
||||
return $this->batchId;
|
||||
}
|
||||
|
||||
public function createActionLog(Action $action, Model $record, ?bool $shouldCreateNewBatchId = true): void
|
||||
{
|
||||
if ($shouldCreateNewBatchId) {
|
||||
$this->createBatchId();
|
||||
}
|
||||
|
||||
$this->recordLog = $record;
|
||||
|
||||
$actionLog = ActionLog::modelActioned(
|
||||
$this->batchId,
|
||||
$action,
|
||||
$this->recordLog,
|
||||
);
|
||||
|
||||
$this->actionLog = $actionLog;
|
||||
}
|
||||
|
||||
public function updateLog(Model $relatedModel, Model $pivot): void
|
||||
{
|
||||
$this->actionLog->update([
|
||||
ActionLog::ATTRIBUTE_TARGET_TYPE => $relatedModel->getMorphClass(),
|
||||
ActionLog::ATTRIBUTE_TARGET_ID => $relatedModel->getKey(),
|
||||
ActionLog::ATTRIBUTE_MODEL_TYPE => $pivot->getMorphClass(),
|
||||
ActionLog::ATTRIBUTE_MODEL_ID => $pivot->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function failedLog(Throwable|string|null $exception): void
|
||||
{
|
||||
$this->actionLog->failed($exception);
|
||||
|
||||
// Filament notifications
|
||||
if ($this instanceof Action) {
|
||||
$this->failureNotificationTitle(Str::limit($exception, 200));
|
||||
$this->failure();
|
||||
}
|
||||
}
|
||||
|
||||
public function finishedLog(): void
|
||||
{
|
||||
if (($actionLog = $this->actionLog) && ! $this->hasFailedLog()) {
|
||||
$actionLog->finished();
|
||||
// Filament notifications
|
||||
if ($this instanceof Action) {
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function batchFinishedLog(): void
|
||||
{
|
||||
$this->actionLog->batchFinished();
|
||||
}
|
||||
|
||||
public function hasFailedLog(): bool
|
||||
{
|
||||
return $this->actionLog->hasFailed();
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Filament\ActionLogs;
|
||||
|
||||
use App\Filament\RelationManagers\BaseRelationManager;
|
||||
use App\Models\Admin\ActionLog;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
trait HasPivotActionLogs
|
||||
{
|
||||
public function pivotActionLog(string $actionName, BaseRelationManager $livewire, Model $record, ?Action $action = null): void
|
||||
{
|
||||
$ownerRecord = $livewire->getOwnerRecord();
|
||||
|
||||
$relation = $livewire->getRelationship();
|
||||
|
||||
if ($relation instanceof BelongsToMany) {
|
||||
ActionLog::modelPivot(
|
||||
$actionName,
|
||||
$ownerRecord,
|
||||
$record,
|
||||
$record->getRelationValue($relation->getPivotAccessor()) ?? $record,
|
||||
$action,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function associateActionLog(string $actionName, BaseRelationManager $livewire, Model $record, Action $action): void
|
||||
{
|
||||
$ownerRecord = $livewire->getOwnerRecord();
|
||||
|
||||
$relation = $livewire->getRelationship();
|
||||
|
||||
if ($relation instanceof HasMany) {
|
||||
ActionLog::modelAssociated(
|
||||
$actionName,
|
||||
$ownerRecord,
|
||||
$record,
|
||||
$action,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Filament\ActionLogs;
|
||||
|
||||
use App\Models\Admin\ActionLog;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
trait ModelHasActionLogs
|
||||
{
|
||||
public function actionlogs(): MorphMany
|
||||
{
|
||||
return $this->morphMany(ActionLog::class, 'actionable');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\Filament;
|
||||
|
||||
use App\Enums\Models\Admin\ActivityStatus;
|
||||
use App\Models\Admin\Activity;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
trait HasActivityLogs
|
||||
{
|
||||
protected ?Activity $activity = null;
|
||||
|
||||
public function createActivityLog(Action $action, Model $record): void
|
||||
{
|
||||
/** @phpstan-ignore-next-line */
|
||||
$this->activity = activity()
|
||||
->performedOn($record)
|
||||
->withProperties($action->getData())
|
||||
->tap(function (Activity $activity): void {
|
||||
$activity->status = ActivityStatus::RUNNING;
|
||||
})
|
||||
->event($action->getLabel())
|
||||
->log('actioned');
|
||||
}
|
||||
|
||||
public function failedLog(Throwable|string|null $exception): void
|
||||
{
|
||||
$this->activity?->update([
|
||||
Activity::ATTRIBUTE_STATUS => ActivityStatus::FAILED,
|
||||
Activity::ATTRIBUTE_EXCEPTION => Str::limit($exception, 200),
|
||||
Activity::ATTRIBUTE_FINISHED_AT => now(),
|
||||
]);
|
||||
|
||||
// Filament notifications
|
||||
if ($this instanceof Action) {
|
||||
$this->failureNotificationTitle(Str::limit($exception, 200));
|
||||
$this->failure();
|
||||
}
|
||||
}
|
||||
|
||||
public function finishedLog(): void
|
||||
{
|
||||
if (! $this->hasFailedLog()) {
|
||||
$this->activity?->update([
|
||||
Activity::ATTRIBUTE_STATUS => ActivityStatus::FINISHED,
|
||||
Activity::ATTRIBUTE_FINISHED_AT => now(),
|
||||
]);
|
||||
|
||||
// Filament notifications
|
||||
if ($this instanceof Action) {
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hasFailedLog(): bool
|
||||
{
|
||||
return $this->activity?->status === ActivityStatus::FAILED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\GraphQL;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
trait BindModels
|
||||
{
|
||||
/**
|
||||
* @template TModel of Model
|
||||
*
|
||||
* @param class-string<TModel> $model
|
||||
* @return ?TModel
|
||||
*/
|
||||
protected function bind(string $model, string $column, string|int $value): ?Model
|
||||
{
|
||||
return $model::query()
|
||||
->firstWhere($column, $value);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\GraphQL;
|
||||
|
||||
use App\Contracts\GraphQL\Fields\BindableField;
|
||||
use App\Contracts\GraphQL\Fields\CreatableField;
|
||||
use App\Contracts\GraphQL\Fields\RequiredOnCreation;
|
||||
use App\Contracts\GraphQL\Fields\RequiredOnUpdate;
|
||||
use App\Contracts\GraphQL\Fields\UpdatableField;
|
||||
use App\GraphQL\Argument\Argument;
|
||||
use App\GraphQL\Argument\BindableArgument;
|
||||
use App\GraphQL\Schema\Fields\Field;
|
||||
|
||||
trait ResolvesArguments
|
||||
{
|
||||
/**
|
||||
* Resolve the args.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function args(): array
|
||||
{
|
||||
return collect($this->arguments())
|
||||
->mapWithKeys(fn (Argument $argument): array => [
|
||||
$argument->getName() => [
|
||||
'name' => $argument->getName(),
|
||||
'type' => $argument->getType(),
|
||||
|
||||
...(is_null($argument->getDefaultValue()) ? [] : ['defaultValue' => $argument->getDefaultValue()]),
|
||||
],
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the fields into arguments that are used for mutations of type create.
|
||||
*
|
||||
* @param Field[] $fields
|
||||
* @return Argument[]
|
||||
*/
|
||||
protected function resolveCreateMutationArguments(array $fields): array
|
||||
{
|
||||
return collect($fields)
|
||||
->filter(fn (Field $field): bool => $field instanceof CreatableField)
|
||||
->map(
|
||||
fn (Field $field): Argument => new Argument($field->name(), $field->baseType())
|
||||
->required($field instanceof RequiredOnCreation)
|
||||
)
|
||||
->flatten()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the fields into arguments that are used for mutations of type update.
|
||||
*
|
||||
* @param Field[] $fields
|
||||
* @return Argument[]
|
||||
*/
|
||||
protected function resolveUpdateMutationArguments(array $fields): array
|
||||
{
|
||||
return collect($fields)
|
||||
->filter(fn (Field $field): bool => $field instanceof UpdatableField)
|
||||
->map(
|
||||
fn (Field $field): Argument => new Argument($field->name(), $field->baseType())
|
||||
->required($field instanceof RequiredOnUpdate)
|
||||
)
|
||||
->flatten()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Field[] $fields
|
||||
* @return BindableArgument[]
|
||||
*/
|
||||
protected function resolveBindArguments(array $fields, bool $shouldRequire = true): array
|
||||
{
|
||||
return collect($fields)
|
||||
->filter(fn (Field $field): bool => $field instanceof BindableField)
|
||||
->map(fn (Field&BindableField $field): BindableArgument => new BindableArgument($field, $shouldRequire))
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\GraphQL;
|
||||
|
||||
use Illuminate\Pipeline\Pipeline;
|
||||
|
||||
trait RunMiddlewares
|
||||
{
|
||||
protected function runHttpMiddleware(array $middleware = []): void
|
||||
{
|
||||
resolve(Pipeline::class)
|
||||
->send(request())
|
||||
->through($middleware)
|
||||
->thenReturn();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Concerns\GraphQL;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Nuwave\Lighthouse\Execution\ResolveInfo;
|
||||
use Nuwave\Lighthouse\Validation\Validator as LighthouseValidator;
|
||||
|
||||
trait ValidateArgs
|
||||
{
|
||||
/**
|
||||
* @param class-string<LighthouseValidator> $validator
|
||||
*/
|
||||
protected function validated(string $validator, ResolveInfo $resolveInfo): array
|
||||
{
|
||||
$validator = new $validator;
|
||||
|
||||
$validator->setArgs($resolveInfo->argumentSet);
|
||||
|
||||
return Validator::make(
|
||||
$resolveInfo->argumentSet->toArray(),
|
||||
$validator->rules(),
|
||||
$validator->messages(),
|
||||
$validator->attributes()
|
||||
)->validated();
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,9 @@ use App\Console\Commands\BaseCommand;
|
||||
use Database\Seeders\Admin\Feature\FeatureSeeder;
|
||||
use Database\Seeders\Auth\Permission\PermissionSeeder;
|
||||
use Database\Seeders\Auth\Role\RoleSeeder;
|
||||
use Database\Seeders\Scout\ImportModelsSeeder;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -62,19 +60,19 @@ class DatabaseSyncCommand extends BaseCommand
|
||||
DB::unprepared($content);
|
||||
|
||||
$this->info('Migrating database');
|
||||
Artisan::call('migrate');
|
||||
$this->call('migrate');
|
||||
|
||||
$this->info('Seeding permissions');
|
||||
Artisan::call('db:seed', ['class' => PermissionSeeder::class]);
|
||||
$this->call('db:seed', ['class' => PermissionSeeder::class]);
|
||||
|
||||
$this->info('Seeding roles');
|
||||
Artisan::call('db:seed', ['class' => RoleSeeder::class]);
|
||||
$this->call('db:seed', ['class' => RoleSeeder::class]);
|
||||
|
||||
$this->info('Seeding features');
|
||||
Artisan::call('db:seed', ['class' => FeatureSeeder::class]);
|
||||
$this->call('db:seed', ['class' => FeatureSeeder::class]);
|
||||
|
||||
$this->info('Importing models for scout');
|
||||
Artisan::call('db:seed', ['class' => ImportModelsSeeder::class]);
|
||||
$this->call('scout:import-all');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands\GraphQL;
|
||||
|
||||
use App\Console\Commands\BaseCommand;
|
||||
use GraphQL\Utils\SchemaPrinter;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Support\Facades\Validator as ValidatorFacade;
|
||||
use Rebing\GraphQL\Support\Facades\GraphQL;
|
||||
|
||||
#[Signature('graphql:print-schema {schema=v1}')]
|
||||
#[Description('Print the GraphQL schema into SDL')]
|
||||
class GraphQLPrintSchemaCommand extends BaseCommand
|
||||
{
|
||||
public function handle(): int
|
||||
{
|
||||
$schemaName = $this->argument('schema');
|
||||
|
||||
$schema = GraphQL::schema($schemaName);
|
||||
|
||||
$sdl = SchemaPrinter::doPrint($schema);
|
||||
|
||||
$this->line($sdl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function validator(): Validator
|
||||
{
|
||||
return ValidatorFacade::make($this->options(), []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands\Models;
|
||||
|
||||
use App\Console\Commands\BaseCommand;
|
||||
use App\Models\List\Playlist;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use App\Models\Wiki\Artist;
|
||||
use App\Models\Wiki\Series;
|
||||
use App\Models\Wiki\Song;
|
||||
use App\Models\Wiki\Studio;
|
||||
use App\Models\Wiki\Synonym;
|
||||
use App\Models\Wiki\Video;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Validator as ValidatorFacade;
|
||||
|
||||
#[Signature(
|
||||
'scout:import-all
|
||||
{--flush : Flush and re-import models}'
|
||||
)]
|
||||
#[Description('Import the models for Laravel Scout')]
|
||||
class ImportModelsCommand extends BaseCommand
|
||||
{
|
||||
public function handle(): int
|
||||
{
|
||||
if (Config::get('app.env') === 'staging') {
|
||||
$this->alert('This seeder is not allowed in staging environments.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$driver = Config::get('scout.driver');
|
||||
if (blank($driver)) {
|
||||
$this->error('No driver configured for Scout. Skipping models importing.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($this->option('flush')) {
|
||||
$this->scoutFlush(Playlist::class);
|
||||
$this->scoutFlush(Anime::class);
|
||||
$this->scoutFlush(AnimeTheme::class);
|
||||
$this->scoutFlush(AnimeThemeEntry::class);
|
||||
$this->scoutFlush(Artist::class);
|
||||
$this->scoutFlush(Series::class);
|
||||
$this->scoutFlush(Song::class);
|
||||
$this->scoutFlush(Studio::class);
|
||||
$this->scoutFlush(Synonym::class);
|
||||
$this->scoutFlush(Video::class);
|
||||
}
|
||||
|
||||
$this->scoutImport(Playlist::class);
|
||||
$this->scoutImport(Anime::class);
|
||||
$this->scoutImport(AnimeTheme::class);
|
||||
$this->scoutImport(AnimeThemeEntry::class);
|
||||
$this->scoutImport(Artist::class);
|
||||
$this->scoutImport(Series::class);
|
||||
$this->scoutImport(Song::class);
|
||||
$this->scoutImport(Studio::class);
|
||||
$this->scoutImport(Synonym::class);
|
||||
$this->scoutImport(Video::class);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the scout import command for the given model.
|
||||
*
|
||||
* @param class-string<Model> $modelClass
|
||||
*/
|
||||
private function scoutImport(string $modelClass): void
|
||||
{
|
||||
$this->info("Importing Models for {$modelClass}");
|
||||
$this->call('scout:import', ['model' => $modelClass]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the scout flush command for the given model.
|
||||
*
|
||||
* @param class-string<Model> $modelClass
|
||||
*/
|
||||
private function scoutFlush(string $modelClass): void
|
||||
{
|
||||
$this->info("Flushing Models for {$modelClass}");
|
||||
$this->call('scout:flush', ['model' => $modelClass]);
|
||||
}
|
||||
|
||||
protected function validator(): Validator
|
||||
{
|
||||
return ValidatorFacade::make($this->options(), [
|
||||
'flush' => ['boolean'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands\Models;
|
||||
|
||||
use App\Actions\ActionResult;
|
||||
use App\Actions\Models\Wiki\Anime\AnimeDateAction;
|
||||
use App\Console\Commands\BaseCommand;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Facades\Validator as ValidatorFacade;
|
||||
use Illuminate\Support\Sleep;
|
||||
|
||||
#[Signature('anime:update-dates')]
|
||||
#[Description('Updates anime dates')]
|
||||
class UpdateAnimeDateCommand extends BaseCommand
|
||||
{
|
||||
public function handle(): int
|
||||
{
|
||||
$failed = false;
|
||||
|
||||
Anime::query()
|
||||
->where(function (Builder $query): void {
|
||||
$query
|
||||
->whereNull(Anime::ATTRIBUTE_START_DATE)
|
||||
->orWhereRaw('RIGHT('.Anime::ATTRIBUTE_START_DATE.', 2) = ?', ['00'])
|
||||
->orWhereNull(Anime::ATTRIBUTE_END_DATE)
|
||||
->orWhereRaw('RIGHT('.Anime::ATTRIBUTE_END_DATE.', 2) = ?', ['00']);
|
||||
})
|
||||
->with([
|
||||
Anime::RELATION_RESOURCES => fn (Relation $query) => $query->where(ExternalResource::ATTRIBUTE_SITE, ResourceSite::ANILIST->value),
|
||||
])
|
||||
->chunkById(20, function (Collection $anime) use (&$failed) {
|
||||
$this->info('Anime IDs: '.$anime->pluck(Anime::ATTRIBUTE_ID)->values()->implode(', '));
|
||||
|
||||
$action = new AnimeDateAction();
|
||||
|
||||
$result = Anime::withoutEvents(fn () => Anime::withoutTimestamps(fn (): ActionResult => $action->handle($anime)));
|
||||
|
||||
if ($result->hasFailed()) {
|
||||
$this->error('Action failed: '.$result->getMessage());
|
||||
|
||||
$failed = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Sleep::sleep(5);
|
||||
});
|
||||
|
||||
return $failed ? 1 : 0;
|
||||
}
|
||||
|
||||
protected function validator(): Validator
|
||||
{
|
||||
return ValidatorFacade::make($this->options(), []);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands\Storage\Admin;
|
||||
|
||||
use App\Actions\Storage\Admin\Dump\DumpDiscordAction;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
|
||||
#[Signature(
|
||||
'db:dump-discord
|
||||
{--comments : Write additional information in the MySQL dump such as program version, server version and host}
|
||||
{--data-only : Dump only the data without the schema in PostgreSQL dump}
|
||||
{--default-character-set=utf8 : Specify default character set in MySQL dump}
|
||||
{--extended-insert : Use multiple-row insert syntax in MySQL dump}
|
||||
{--inserts : Dump data as INSERT commands rather than COPY in PostgreSQL dump}
|
||||
{--lock-tables : Lock all tables before dumping them to MySQL dump}
|
||||
{--no-create-info : Turn off CREATE TABLE statements in MySQL dump}
|
||||
{--quick : Retrieve rows for a table from the server one row at a time in MySQL dump}
|
||||
{--set-gtid-purged=AUTO : Add SET GTID_PURGED to output in MySQL dump}
|
||||
{--single-transaction=true : Issue a BEGIN SQL statement before dumping data from server for MySQL dump}
|
||||
{--skip-column-statistics : Turn off ANALYZE table statements in the MySQL dump}
|
||||
{--skip-comments : Do not write additional information in the MySQL dump}
|
||||
{--skip-extended-insert : Turn off extended-insert in MySQL dump}
|
||||
{--skip-lock-tables : Turn off locking tables before dumping to MySQL dump}
|
||||
{--skip-quick : Do not retrieve rows for a table from the server one row at a time in MySQL dump}'
|
||||
)]
|
||||
#[Description('Produces sanitized database dump, targeting discord-related tables for seeding purposes')]
|
||||
class DiscordDumpCommand extends DumpCommand
|
||||
{
|
||||
protected function action(): DumpDiscordAction
|
||||
{
|
||||
return new DumpDiscordAction($this->options());
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ namespace App\Console\Commands\Storage\Base;
|
||||
|
||||
use App\Actions\Storage\Base\PruneAction;
|
||||
use App\Console\Commands\Storage\StorageCommand;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Support\Facades\Validator as ValidatorFacade;
|
||||
|
||||
#[Description('Prune stale files from storage')]
|
||||
abstract class PruneCommand extends StorageCommand
|
||||
{
|
||||
protected $description = 'Prune stale files from storage';
|
||||
|
||||
abstract protected function getAction(): PruneAction;
|
||||
|
||||
protected function validator(): Validator
|
||||
|
||||
@@ -5,11 +5,11 @@ declare(strict_types=1);
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\Models\SyncLikeAggregatesCommand;
|
||||
use App\Console\Commands\Models\UpdateAnimeDateCommand;
|
||||
use App\Console\Commands\Repositories\Storage\Admin\DumpReconcileCommand;
|
||||
use App\Console\Commands\Storage\Admin\AdminDumpCommand;
|
||||
use App\Console\Commands\Storage\Admin\AuthDumpCommand;
|
||||
use App\Console\Commands\Storage\Admin\ContentDumpCommand;
|
||||
use App\Console\Commands\Storage\Admin\DiscordDumpCommand;
|
||||
use App\Console\Commands\Storage\Admin\DocumentDumpCommand;
|
||||
use App\Console\Commands\Storage\Admin\DumpPruneCommand;
|
||||
use App\Console\Commands\Storage\Admin\ListDumpCommand;
|
||||
@@ -61,12 +61,6 @@ class Kernel extends ConsoleKernel
|
||||
->storeOutput()
|
||||
->weeklyOn(Schedule::MONDAY);
|
||||
|
||||
$schedule->command(DiscordDumpCommand::class)
|
||||
->withoutOverlapping()
|
||||
->runInBackground()
|
||||
->storeOutput()
|
||||
->weeklyOn(Schedule::MONDAY);
|
||||
|
||||
$schedule->command(DocumentDumpCommand::class)
|
||||
->withoutOverlapping()
|
||||
->runInBackground()
|
||||
@@ -151,6 +145,12 @@ class Kernel extends ConsoleKernel
|
||||
->storeOutput()
|
||||
->daily();
|
||||
|
||||
$schedule->command(UpdateAnimeDateCommand::class)
|
||||
->withoutOverlapping()
|
||||
->runInBackground()
|
||||
->storeOutput()
|
||||
->dailyAt('23:30');
|
||||
|
||||
$schedule->command(UpdateDisposableDomainsCommand::class)
|
||||
->withoutOverlapping()
|
||||
->runInBackground()
|
||||
|
||||
@@ -8,7 +8,6 @@ class ServiceConstants
|
||||
{
|
||||
final public const string ADMIN_DISCORD_CHANNEL_QUALIFIED = 'services.discord.admin_discord_channel';
|
||||
final public const string DB_UPDATES_DISCORD_CHANNEL_QUALIFIED = 'services.discord.db_updates_discord_channel';
|
||||
final public const string SUBMISSIONS_DISCORD_CHANNEL_QUALIFIED = 'services.discord.submissions_discord_channel';
|
||||
|
||||
final public const string OPENAI_BEARER_TOKEN = 'services.openai.token';
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\Events;
|
||||
|
||||
use Illuminate\Contracts\Events\ShouldHandleEventsAfterCommit;
|
||||
|
||||
interface UpdateAnimeSynonymsEvent extends ShouldHandleEventsAfterCommit
|
||||
{
|
||||
public function updateAnimeSynonyms(): void;
|
||||
}
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
namespace App\Contracts\GraphQL;
|
||||
|
||||
use App\GraphQL\Filter\Filter;
|
||||
|
||||
interface FilterableField
|
||||
interface EnumFilterableColumns
|
||||
{
|
||||
public function getFilter(): Filter;
|
||||
}
|
||||
@@ -4,11 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL;
|
||||
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
|
||||
interface EnumSort
|
||||
{
|
||||
public function getSortCriteria(): SortCriteria;
|
||||
|
||||
public function shouldQualifyColumn(): bool;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
interface BindableField
|
||||
{
|
||||
/**
|
||||
* The resolver to cast the model.
|
||||
*/
|
||||
public function bindResolver(array $args): ?Model;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface CreatableField
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $args
|
||||
*/
|
||||
public function getCreationRules(array $args): array;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface DeprecatedField
|
||||
{
|
||||
public function deprecationReason(): string;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface DisplayableField
|
||||
{
|
||||
public function canBeDisplayed(): bool;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface RequiredOnCreation {}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface RequiredOnUpdate {}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\GraphQL\Fields;
|
||||
|
||||
interface UpdatableField
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $args
|
||||
*/
|
||||
public function getUpdateRules(array $args): array;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Field;
|
||||
|
||||
enum AggregateFunction: string
|
||||
{
|
||||
case AVG = 'avg';
|
||||
case COUNT = 'count';
|
||||
case EXISTS = 'exists';
|
||||
case MAX = 'max';
|
||||
case MIN = 'min';
|
||||
case SUM = 'sum';
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Admin;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Admin\Announcement;
|
||||
|
||||
enum AnnouncementFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case CONTENT;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Announcement::ATTRIBUTE_ID),
|
||||
self::CONTENT => new StringFilter($this->name, Announcement::ATTRIBUTE_CONTENT),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Announcement::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Announcement::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Admin;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Admin\Dump;
|
||||
|
||||
enum DumpFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case PATH;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Dump::ATTRIBUTE_ID),
|
||||
self::PATH => new StringFilter($this->name, Dump::ATTRIBUTE_PATH),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Dump::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Dump::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter;
|
||||
|
||||
enum Clause
|
||||
{
|
||||
case WHERE;
|
||||
case HAVING;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter;
|
||||
|
||||
use App\Concerns\Enums\CoercesInstances;
|
||||
|
||||
enum ComparisonOperator: string
|
||||
{
|
||||
use CoercesInstances;
|
||||
|
||||
case EQ = '=';
|
||||
case NE = '<>';
|
||||
case LT = '<';
|
||||
case GT = '>';
|
||||
case LTE = '<=';
|
||||
case GTE = '>=';
|
||||
case LIKE = 'like';
|
||||
case NOTLIKE = 'not like';
|
||||
case IN = 'in';
|
||||
case NOTIN = 'not in';
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Document;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Document\Page;
|
||||
|
||||
enum PageFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SLUG;
|
||||
case BODY;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Page::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Page::ATTRIBUTE_NAME),
|
||||
self::SLUG => new StringFilter($this->name, Page::ATTRIBUTE_SLUG),
|
||||
self::BODY => new StringFilter($this->name, Page::ATTRIBUTE_BODY),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Page::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Page::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\List;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\List\ExternalProfileSite;
|
||||
use App\Enums\Models\List\ExternalProfileVisibility;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\List\ExternalProfile;
|
||||
|
||||
enum ExternalProfileFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SITE;
|
||||
case VISIBILITY;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, ExternalProfile::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, ExternalProfile::ATTRIBUTE_NAME),
|
||||
self::SITE => new EnumFilter($this->name, ExternalProfileSite::class, ExternalProfile::ATTRIBUTE_SITE),
|
||||
self::VISIBILITY => new EnumFilter($this->name, ExternalProfileVisibility::class, ExternalProfile::ATTRIBUTE_VISIBILITY),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, ExternalProfile::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, ExternalProfile::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\List\Playlist;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
|
||||
enum PlaylistTrackFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case POSITION;
|
||||
case ENTRY_ID;
|
||||
case VIDEO_ID;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, PlaylistTrack::ATTRIBUTE_ID),
|
||||
self::POSITION => new IntFilter($this->name, PlaylistTrack::ATTRIBUTE_POSITION),
|
||||
self::ENTRY_ID => new IntFilter($this->name, PlaylistTrack::ATTRIBUTE_ENTRY),
|
||||
self::VIDEO_ID => new IntFilter($this->name, PlaylistTrack::ATTRIBUTE_VIDEO),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, PlaylistTrack::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, PlaylistTrack::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\List;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\List\PlaylistVisibility;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\List\Playlist;
|
||||
|
||||
enum PlaylistFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case VISIBILITY;
|
||||
case DESCRIPTION;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Playlist::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Playlist::ATTRIBUTE_NAME),
|
||||
self::VISIBILITY => new EnumFilter($this->name, PlaylistVisibility::class, Playlist::ATTRIBUTE_VISIBILITY),
|
||||
self::DESCRIPTION => new StringFilter($this->name, Playlist::ATTRIBUTE_DESCRIPTION),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Playlist::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Playlist::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter;
|
||||
|
||||
use App\Concerns\Enums\CoercesInstances;
|
||||
|
||||
enum LogicalOperator: string
|
||||
{
|
||||
use CoercesInstances;
|
||||
|
||||
case AND = 'and';
|
||||
case OR = 'or';
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki\Anime;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\ThemeType;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
|
||||
enum AnimeThemeFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case TYPE;
|
||||
case SEQUENCE;
|
||||
case SLUG;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, AnimeTheme::ATTRIBUTE_ID),
|
||||
self::TYPE => new EnumFilter($this->name, ThemeType::class, AnimeTheme::ATTRIBUTE_TYPE),
|
||||
self::SEQUENCE => new IntFilter($this->name, AnimeTheme::ATTRIBUTE_SEQUENCE),
|
||||
self::SLUG => new StringFilter($this->name, AnimeTheme::ATTRIBUTE_SLUG),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, AnimeTheme::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, AnimeTheme::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki\Anime\Theme;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\BooleanFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
|
||||
enum AnimeThemeEntryFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case EPISODES;
|
||||
case NOTES;
|
||||
case NSFW;
|
||||
case SPOILER;
|
||||
case VERSION;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
self::EPISODES => new StringFilter($this->name, AnimeThemeEntry::ATTRIBUTE_EPISODES),
|
||||
self::NOTES => new StringFilter($this->name, AnimeThemeEntry::ATTRIBUTE_NOTES),
|
||||
self::NSFW => new BooleanFilter($this->name, AnimeThemeEntry::ATTRIBUTE_NSFW),
|
||||
self::SPOILER => new BooleanFilter($this->name, AnimeThemeEntry::ATTRIBUTE_SPOILER),
|
||||
self::VERSION => new IntFilter($this->name, AnimeThemeEntry::ATTRIBUTE_VERSION),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, AnimeThemeEntry::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, AnimeThemeEntry::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\AnimeFormat;
|
||||
use App\Enums\Models\Wiki\AnimeSeason;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\FuzzyDateFilter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Anime;
|
||||
use GraphQL\Type\Definition\Deprecated;
|
||||
|
||||
enum AnimeFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case FORMAT;
|
||||
case SEASON;
|
||||
case START_DATE;
|
||||
case END_DATE;
|
||||
case SYNOPSIS;
|
||||
#[Deprecated('Use the `START_DATE` filter instead.')]
|
||||
case YEAR;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Anime::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Anime::ATTRIBUTE_NAME),
|
||||
self::FORMAT => new EnumFilter($this->name, AnimeFormat::class, Anime::ATTRIBUTE_FORMAT),
|
||||
self::SEASON => new EnumFilter($this->name, AnimeSeason::class, Anime::ATTRIBUTE_SEASON),
|
||||
self::START_DATE => new FuzzyDateFilter($this->name, Anime::ATTRIBUTE_START_DATE),
|
||||
self::END_DATE => new FuzzyDateFilter($this->name, Anime::ATTRIBUTE_END_DATE),
|
||||
self::YEAR => new IntFilter($this->name, Anime::ATTRIBUTE_YEAR),
|
||||
self::SYNOPSIS => new StringFilter($this->name, Anime::ATTRIBUTE_SYNOPSIS),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Anime::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Anime::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Artist;
|
||||
|
||||
enum ArtistFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SLUG;
|
||||
case INFORMATION;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Artist::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Artist::ATTRIBUTE_NAME),
|
||||
self::SLUG => new StringFilter($this->name, Artist::ATTRIBUTE_SLUG),
|
||||
self::INFORMATION => new StringFilter($this->name, Artist::ATTRIBUTE_INFORMATION),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Artist::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Artist::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Audio;
|
||||
|
||||
enum AudioFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case BASENAME;
|
||||
case FILENAME;
|
||||
case MIMETYPE;
|
||||
case SIZE;
|
||||
case PATH;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Audio::ATTRIBUTE_ID),
|
||||
self::BASENAME => new StringFilter($this->name, Audio::ATTRIBUTE_BASENAME),
|
||||
self::FILENAME => new StringFilter($this->name, Audio::ATTRIBUTE_FILENAME),
|
||||
self::MIMETYPE => new StringFilter($this->name, Audio::ATTRIBUTE_MIMETYPE),
|
||||
self::SIZE => new IntFilter($this->name, Audio::ATTRIBUTE_SIZE),
|
||||
self::PATH => new StringFilter($this->name, Audio::ATTRIBUTE_PATH),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Audio::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Audio::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
|
||||
enum ExternalResourceFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case EXTERNAL_ID;
|
||||
case LINK;
|
||||
case SITE;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, ExternalResource::ATTRIBUTE_ID),
|
||||
self::EXTERNAL_ID => new IntFilter($this->name, ExternalResource::ATTRIBUTE_EXTERNAL_ID),
|
||||
self::LINK => new StringFilter($this->name, ExternalResource::ATTRIBUTE_LINK),
|
||||
self::SITE => new EnumFilter($this->name, ResourceSite::class, ExternalResource::ATTRIBUTE_SITE),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, ExternalResource::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, ExternalResource::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\ImageFacet;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Image;
|
||||
|
||||
enum ImageFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case FACET;
|
||||
case PATH;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Image::ATTRIBUTE_ID),
|
||||
self::FACET => new EnumFilter($this->name, ImageFacet::class, Image::ATTRIBUTE_FACET),
|
||||
self::PATH => new StringFilter($this->name, Image::ATTRIBUTE_PATH),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Image::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Image::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Series;
|
||||
|
||||
enum SeriesFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SLUG;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Series::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Series::ATTRIBUTE_NAME),
|
||||
self::SLUG => new StringFilter($this->name, Series::ATTRIBUTE_SLUG),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Series::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Series::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki\Song;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Song\Performance;
|
||||
|
||||
enum PerformanceFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case ALIAS;
|
||||
case AS;
|
||||
case MEMBER_ALIAS;
|
||||
case MEMBER_AS;
|
||||
case RELEVANCE;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Performance::ATTRIBUTE_ID),
|
||||
self::ALIAS => new StringFilter($this->name, Performance::ATTRIBUTE_ALIAS),
|
||||
self::AS => new StringFilter($this->name, Performance::ATTRIBUTE_AS),
|
||||
self::MEMBER_ALIAS => new StringFilter($this->name, Performance::ATTRIBUTE_MEMBER_ALIAS),
|
||||
self::MEMBER_AS => new StringFilter($this->name, Performance::ATTRIBUTE_MEMBER_AS),
|
||||
self::RELEVANCE => new IntFilter($this->name, Performance::ATTRIBUTE_RELEVANCE),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Performance::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Performance::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Song;
|
||||
|
||||
enum SongFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case TITLE;
|
||||
case TITLE_NATIVE;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Song::ATTRIBUTE_ID),
|
||||
self::TITLE => new StringFilter($this->name, Song::ATTRIBUTE_TITLE),
|
||||
self::TITLE_NATIVE => new StringFilter($this->name, Song::ATTRIBUTE_TITLE_NATIVE),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Song::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Song::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Studio;
|
||||
|
||||
enum StudioFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SLUG;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Studio::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Studio::ATTRIBUTE_NAME),
|
||||
self::SLUG => new StringFilter($this->name, Studio::ATTRIBUTE_SLUG),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Studio::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Studio::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\SynonymType;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Synonym;
|
||||
|
||||
enum SynonymFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case TEXT;
|
||||
case TYPE;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Synonym::ATTRIBUTE_ID),
|
||||
self::TEXT => new StringFilter($this->name, Synonym::ATTRIBUTE_TEXT),
|
||||
self::TYPE => new EnumFilter($this->name, SynonymType::class, Synonym::ATTRIBUTE_TYPE),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Synonym::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Synonym::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Group;
|
||||
|
||||
enum ThemeGroupFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case NAME;
|
||||
case SLUG;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Group::ATTRIBUTE_ID),
|
||||
self::NAME => new StringFilter($this->name, Group::ATTRIBUTE_NAME),
|
||||
self::SLUG => new StringFilter($this->name, Group::ATTRIBUTE_SLUG),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Group::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Group::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Filter\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumFilterableColumns;
|
||||
use App\Enums\Models\Wiki\VideoOverlap;
|
||||
use App\Enums\Models\Wiki\VideoSource;
|
||||
use App\GraphQL\Filter\BooleanFilter;
|
||||
use App\GraphQL\Filter\EnumFilter;
|
||||
use App\GraphQL\Filter\Filter;
|
||||
use App\GraphQL\Filter\IntFilter;
|
||||
use App\GraphQL\Filter\StringFilter;
|
||||
use App\GraphQL\Filter\TimestampFilter;
|
||||
use App\Models\Wiki\Video;
|
||||
|
||||
enum VideoFilterableColumns implements EnumFilterableColumns
|
||||
{
|
||||
case ID;
|
||||
case BASENAME;
|
||||
case FILENAME;
|
||||
case LYRICS;
|
||||
case MIMETYPE;
|
||||
case NC;
|
||||
case OVERLAP;
|
||||
case PATH;
|
||||
case RESOLUTION;
|
||||
case SIZE;
|
||||
case SOURCE;
|
||||
case SUBBED;
|
||||
case UNCEN;
|
||||
case CREATED_AT;
|
||||
case UPDATED_AT;
|
||||
|
||||
public function getFilter(): Filter
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new IntFilter($this->name, Video::ATTRIBUTE_ID),
|
||||
self::BASENAME => new StringFilter($this->name, Video::ATTRIBUTE_BASENAME),
|
||||
self::FILENAME => new StringFilter($this->name, Video::ATTRIBUTE_FILENAME),
|
||||
self::LYRICS => new BooleanFilter($this->name, Video::ATTRIBUTE_LYRICS),
|
||||
self::MIMETYPE => new StringFilter($this->name, Video::ATTRIBUTE_MIMETYPE),
|
||||
self::NC => new BooleanFilter($this->name, Video::ATTRIBUTE_NC),
|
||||
self::OVERLAP => new EnumFilter($this->name, VideoOverlap::class, Video::ATTRIBUTE_OVERLAP),
|
||||
self::PATH => new StringFilter($this->name, Video::ATTRIBUTE_PATH),
|
||||
self::RESOLUTION => new IntFilter($this->name, Video::ATTRIBUTE_RESOLUTION),
|
||||
self::SIZE => new IntFilter($this->name, Video::ATTRIBUTE_SIZE),
|
||||
self::SOURCE => new EnumFilter($this->name, VideoSource::class, Video::ATTRIBUTE_SOURCE),
|
||||
self::SUBBED => new BooleanFilter($this->name, Video::ATTRIBUTE_SUBBED),
|
||||
self::UNCEN => new BooleanFilter($this->name, Video::ATTRIBUTE_UNCEN),
|
||||
self::CREATED_AT => new TimestampFilter($this->name, Video::ATTRIBUTE_CREATED_AT),
|
||||
self::UPDATED_AT => new TimestampFilter($this->name, Video::ATTRIBUTE_UPDATED_AT),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL;
|
||||
|
||||
enum PaginationType
|
||||
{
|
||||
case NONE;
|
||||
case SIMPLE;
|
||||
case PAGINATION;
|
||||
case CONNECTION;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL;
|
||||
|
||||
enum RelationType
|
||||
{
|
||||
case BELONGS_TO;
|
||||
case BELONGS_TO_MANY;
|
||||
case HAS_MANY;
|
||||
case HAS_ONE;
|
||||
case MORPH_MANY;
|
||||
case MORPH_TO;
|
||||
}
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Admin;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Admin\Announcement;
|
||||
|
||||
enum AnnouncementSort implements EnumSort
|
||||
@@ -24,18 +24,13 @@ enum AnnouncementSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Announcement::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Announcement::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Announcement::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Announcement::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Announcement::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Announcement::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Announcement::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Admin;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Admin\Dump;
|
||||
|
||||
enum DumpSort implements EnumSort
|
||||
@@ -24,18 +24,13 @@ enum DumpSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Dump::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Dump::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Dump::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Dump::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Dump::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Dump::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Dump::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Sort\Auth;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Auth\Permission;
|
||||
|
||||
enum PermissionSort implements EnumSort
|
||||
{
|
||||
case ID;
|
||||
case ID_DESC;
|
||||
case NAME;
|
||||
case NAME_DESC;
|
||||
case CREATED_AT;
|
||||
case CREATED_AT_DESC;
|
||||
case UPDATED_AT;
|
||||
case UPDATED_AT_DESC;
|
||||
case RANDOM;
|
||||
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Permission::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Sort\Auth;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Auth\Role;
|
||||
|
||||
enum RoleSort implements EnumSort
|
||||
{
|
||||
case ID;
|
||||
case ID_DESC;
|
||||
case NAME;
|
||||
case NAME_DESC;
|
||||
case PRIORITY;
|
||||
case PRIORITY_DESC;
|
||||
case CREATED_AT;
|
||||
case CREATED_AT_DESC;
|
||||
case UPDATED_AT;
|
||||
case UPDATED_AT_DESC;
|
||||
case RANDOM;
|
||||
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this->name, Role::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Role::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Role::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Role::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::PRIORITY => new FieldSortCriteria($this->name, Role::ATTRIBUTE_PRIORITY),
|
||||
self::PRIORITY_DESC => new FieldSortCriteria($this->name, Role::ATTRIBUTE_PRIORITY, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Role::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Role::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Role::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Role::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Document;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Document\Page;
|
||||
|
||||
enum PageSort implements EnumSort
|
||||
@@ -28,22 +28,17 @@ enum PageSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Page::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Page::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Page::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Page::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::SLUG => new FieldSortCriteria($this, Page::ATTRIBUTE_SLUG, isStringField: true),
|
||||
self::SLUG_DESC => new FieldSortCriteria($this, Page::ATTRIBUTE_SLUG, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Page::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Page::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Page::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Page::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Page::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Page::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Page::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Page::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::SLUG => new FieldSortCriteria($this->name, Page::ATTRIBUTE_SLUG),
|
||||
self::SLUG_DESC => new FieldSortCriteria($this->name, Page::ATTRIBUTE_SLUG, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Page::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Page::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Page::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Page::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\List\Playlist;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
|
||||
enum PlaylistTrackSort implements EnumSort
|
||||
@@ -26,20 +26,15 @@ enum PlaylistTrackSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::POSITION => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_POSITION),
|
||||
self::POSITION_DESC => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_POSITION, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, PlaylistTrack::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::POSITION => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_POSITION),
|
||||
self::POSITION_DESC => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_POSITION, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, PlaylistTrack::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ declare(strict_types=1);
|
||||
namespace App\Enums\GraphQL\Sort\List;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\QualifyColumn;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\Enums\Http\Api\Field\AggregateFunction;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\List\Playlist;
|
||||
|
||||
enum PlaylistSort implements EnumSort
|
||||
@@ -30,30 +32,19 @@ enum PlaylistSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Playlist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Playlist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Playlist::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Playlist::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::LIKES_COUNT => new FieldSortCriteria($this, 'like_aggregate_sum_value'),
|
||||
self::LIKES_COUNT_DESC => new FieldSortCriteria($this, 'like_aggregate_sum_value', SortDirection::DESC),
|
||||
self::TRACKS_COUNT => new FieldSortCriteria($this, 'tracksCount'),
|
||||
self::TRACKS_COUNT_DESC => new FieldSortCriteria($this, 'tracksCount', SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Playlist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Playlist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Playlist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Playlist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::LIKES_COUNT,
|
||||
self::LIKES_COUNT_DESC,
|
||||
self::TRACKS_COUNT,
|
||||
self::TRACKS_COUNT_DESC => false,
|
||||
default => true,
|
||||
self::ID => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::LIKES_COUNT => new FieldSortCriteria($this->name, 'like_aggregate_sum_value', qualifyColumn: QualifyColumn::NO),
|
||||
self::LIKES_COUNT_DESC => new FieldSortCriteria($this->name, 'like_aggregate_sum_value', SortDirection::DESC, QualifyColumn::NO),
|
||||
self::TRACKS_COUNT => new FieldSortCriteria($this->name, 'tracks_count', qualifyColumn: QualifyColumn::NO)->setAggregateRelation(Playlist::RELATION_TRACKS, AggregateFunction::COUNT),
|
||||
self::TRACKS_COUNT_DESC => new FieldSortCriteria($this->name, 'tracks_count', SortDirection::DESC, QualifyColumn::NO)->setAggregateRelation(Playlist::RELATION_TRACKS, AggregateFunction::COUNT),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Playlist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace App\Enums\GraphQL\Sort\Pivot;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\PivotSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\PivotSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Artist;
|
||||
use App\Pivots\Wiki\ArtistMember;
|
||||
|
||||
@@ -34,26 +34,21 @@ enum ArtistMemberSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Artist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Artist::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::MEMBER_ALIAS => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_ALIAS, isStringField: true),
|
||||
self::MEMBER_ALIAS_DESC => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_ALIAS, SortDirection::DESC, isStringField: true),
|
||||
self::MEMBER_AS => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_AS, isStringField: true),
|
||||
self::MEMBER_AS_DESC => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_AS, SortDirection::DESC, isStringField: true),
|
||||
self::MEMBER_RELEVANCE => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_RELEVANCE),
|
||||
self::MEMBER_RELEVANCE_DESC => new PivotSortCriteria($this, ArtistMember::ATTRIBUTE_RELEVANCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Artist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Artist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::MEMBER_ALIAS => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_ALIAS),
|
||||
self::MEMBER_ALIAS_DESC => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_ALIAS, SortDirection::DESC),
|
||||
self::MEMBER_AS => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_AS),
|
||||
self::MEMBER_AS_DESC => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_AS, SortDirection::DESC),
|
||||
self::MEMBER_RELEVANCE => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_RELEVANCE),
|
||||
self::MEMBER_RELEVANCE_DESC => new PivotSortCriteria($this->name, ArtistMember::ATTRIBUTE_RELEVANCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace App\Enums\GraphQL\Sort\Pivot;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\PivotSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\PivotSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Image;
|
||||
use App\Pivots\Morph\Imageable;
|
||||
|
||||
@@ -28,20 +28,15 @@ enum ImageableSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Image::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::DEPTH => new PivotSortCriteria($this, Imageable::ATTRIBUTE_DEPTH),
|
||||
self::DEPTH_DESC => new PivotSortCriteria($this, Imageable::ATTRIBUTE_DEPTH, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Image::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Image::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Image::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::DEPTH => new PivotSortCriteria($this->name, Imageable::ATTRIBUTE_DEPTH),
|
||||
self::DEPTH_DESC => new PivotSortCriteria($this->name, Imageable::ATTRIBUTE_DEPTH, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Image::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Image::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ declare(strict_types=1);
|
||||
namespace App\Enums\GraphQL\Sort\Wiki\Anime\AnimeTheme;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\QualifyColumn;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\Enums\Http\Api\Field\AggregateFunction;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
|
||||
enum AnimeThemeEntrySort implements EnumSort
|
||||
@@ -32,32 +34,21 @@ enum AnimeThemeEntrySort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::EPISODES => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_EPISODES),
|
||||
self::EPISODES_DESC => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_EPISODES, SortDirection::DESC),
|
||||
self::VERSION => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_VERSION),
|
||||
self::VERSION_DESC => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_VERSION, SortDirection::DESC),
|
||||
self::LIKES_COUNT => new FieldSortCriteria($this, 'like_aggregate_sum_value'),
|
||||
self::LIKES_COUNT_DESC => new FieldSortCriteria($this, 'like_aggregate_sum_value', SortDirection::DESC),
|
||||
self::TRACKS_COUNT => new FieldSortCriteria($this, 'tracks_count'),
|
||||
self::TRACKS_COUNT_DESC => new FieldSortCriteria($this, 'tracks_count', SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, AnimeThemeEntry::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::LIKES_COUNT,
|
||||
self::LIKES_COUNT_DESC,
|
||||
self::TRACKS_COUNT,
|
||||
self::TRACKS_COUNT_DESC => false,
|
||||
default => true,
|
||||
self::ID => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::EPISODES => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_EPISODES),
|
||||
self::EPISODES_DESC => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_EPISODES, SortDirection::DESC),
|
||||
self::VERSION => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_VERSION),
|
||||
self::VERSION_DESC => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_VERSION, SortDirection::DESC),
|
||||
self::LIKES_COUNT => new FieldSortCriteria($this->name, 'like_aggregate_sum_value', qualifyColumn: QualifyColumn::NO),
|
||||
self::LIKES_COUNT_DESC => new FieldSortCriteria($this->name, 'like_aggregate_sum_value', SortDirection::DESC, QualifyColumn::NO),
|
||||
self::TRACKS_COUNT => new FieldSortCriteria($this->name, 'tracks_count', qualifyColumn: QualifyColumn::NO)->setAggregateRelation(AnimeThemeEntry::RELATION_TRACKS, AggregateFunction::COUNT),
|
||||
self::TRACKS_COUNT_DESC => new FieldSortCriteria($this->name, 'tracks_count', SortDirection::DESC, QualifyColumn::NO)->setAggregateRelation(AnimeThemeEntry::RELATION_TRACKS, AggregateFunction::COUNT),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, AnimeThemeEntry::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace App\Enums\GraphQL\Sort\Wiki\Anime;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RelationSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\RelationSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Song;
|
||||
|
||||
@@ -32,24 +32,19 @@ enum AnimeThemeSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::SEQUENCE => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_SEQUENCE),
|
||||
self::SEQUENCE_DESC => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_SEQUENCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, AnimeTheme::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::SONG_TITLE => new RelationSortCriteria($this, Song::ATTRIBUTE_TITLE, AnimeTheme::RELATION_SONG, isStringField: true),
|
||||
self::SONG_TITLE_DESC => new RelationSortCriteria($this, Song::ATTRIBUTE_TITLE, AnimeTheme::RELATION_SONG, SortDirection::DESC, isStringField: true),
|
||||
self::SONG_TITLE_NATIVE => new RelationSortCriteria($this, Song::ATTRIBUTE_TITLE_NATIVE, AnimeTheme::RELATION_SONG, isStringField: true),
|
||||
self::SONG_TITLE_NATIVE_DESC => new RelationSortCriteria($this, Song::ATTRIBUTE_TITLE_NATIVE, AnimeTheme::RELATION_SONG, SortDirection::DESC, isStringField: true),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::SEQUENCE => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_SEQUENCE),
|
||||
self::SEQUENCE_DESC => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_SEQUENCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, AnimeTheme::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::SONG_TITLE => new RelationSortCriteria($this->name, Song::ATTRIBUTE_TITLE, AnimeTheme::RELATION_SONG),
|
||||
self::SONG_TITLE_DESC => new RelationSortCriteria($this->name, Song::ATTRIBUTE_TITLE, AnimeTheme::RELATION_SONG, SortDirection::DESC),
|
||||
self::SONG_TITLE_NATIVE => new RelationSortCriteria($this->name, Song::ATTRIBUTE_TITLE_NATIVE, AnimeTheme::RELATION_SONG),
|
||||
self::SONG_TITLE_NATIVE_DESC => new RelationSortCriteria($this->name, Song::ATTRIBUTE_TITLE_NATIVE, AnimeTheme::RELATION_SONG, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Anime;
|
||||
use GraphQL\Type\Definition\Deprecated;
|
||||
|
||||
enum AnimeSort implements EnumSort
|
||||
{
|
||||
@@ -17,7 +18,13 @@ enum AnimeSort implements EnumSort
|
||||
case ID_DESC;
|
||||
case NAME;
|
||||
case NAME_DESC;
|
||||
case START_DATE;
|
||||
case START_DATE_DESC;
|
||||
case END_DATE;
|
||||
case END_DATE_DESC;
|
||||
#[Deprecated('Use the `START_DATE` sort instead.')]
|
||||
case YEAR;
|
||||
#[Deprecated('Use the `START_DATE_DESC` sort instead.')]
|
||||
case YEAR_DESC;
|
||||
case CREATED_AT;
|
||||
case CREATED_AT_DESC;
|
||||
@@ -28,22 +35,21 @@ enum AnimeSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Anime::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Anime::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Anime::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Anime::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::YEAR => new FieldSortCriteria($this, Anime::ATTRIBUTE_YEAR),
|
||||
self::YEAR_DESC => new FieldSortCriteria($this, Anime::ATTRIBUTE_YEAR, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Anime::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Anime::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Anime::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Anime::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::YEAR => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_YEAR),
|
||||
self::YEAR_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_YEAR, SortDirection::DESC),
|
||||
self::START_DATE => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_START_DATE),
|
||||
self::START_DATE_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_START_DATE, SortDirection::DESC),
|
||||
self::END_DATE => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_END_DATE),
|
||||
self::END_DATE_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_END_DATE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Anime::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Artist;
|
||||
|
||||
enum ArtistSort implements EnumSort
|
||||
@@ -26,20 +26,15 @@ enum ArtistSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Artist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Artist::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Artist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Artist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Artist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Artist::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Audio;
|
||||
|
||||
enum AudioSort implements EnumSort
|
||||
@@ -30,24 +30,19 @@ enum AudioSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Audio::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::BASENAME => new FieldSortCriteria($this, Audio::ATTRIBUTE_BASENAME, isStringField: true),
|
||||
self::BASENAME_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_BASENAME, SortDirection::DESC, isStringField: true),
|
||||
self::FILENAME => new FieldSortCriteria($this, Audio::ATTRIBUTE_FILENAME, isStringField: true),
|
||||
self::FILENAME_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_FILENAME, SortDirection::DESC, isStringField: true),
|
||||
self::SIZE => new FieldSortCriteria($this, Audio::ATTRIBUTE_SIZE),
|
||||
self::SIZE_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_SIZE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Audio::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Audio::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Audio::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::BASENAME => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_BASENAME),
|
||||
self::BASENAME_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_BASENAME, SortDirection::DESC),
|
||||
self::FILENAME => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_FILENAME),
|
||||
self::FILENAME_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_FILENAME, SortDirection::DESC),
|
||||
self::SIZE => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_SIZE),
|
||||
self::SIZE_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_SIZE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Audio::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
|
||||
enum ExternalResourceSort implements EnumSort
|
||||
{
|
||||
case ID;
|
||||
case ID_DESC;
|
||||
case SITE;
|
||||
case SITE_DESC;
|
||||
case EXTERNAL_ID;
|
||||
case EXTERNAL_ID_DESC;
|
||||
case LINK;
|
||||
case LINK_DESC;
|
||||
case CREATED_AT;
|
||||
case CREATED_AT_DESC;
|
||||
case UPDATED_AT;
|
||||
case UPDATED_AT_DESC;
|
||||
case RANDOM;
|
||||
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_ID, SortDirection::ASC),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::SITE => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_SITE),
|
||||
self::SITE_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_SITE, SortDirection::DESC),
|
||||
self::EXTERNAL_ID => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_EXTERNAL_ID),
|
||||
self::EXTERNAL_ID_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_EXTERNAL_ID, SortDirection::DESC),
|
||||
self::LINK => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_LINK),
|
||||
self::LINK_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_LINK, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, ExternalResource::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Image;
|
||||
|
||||
enum ImageSort implements EnumSort
|
||||
@@ -24,18 +24,13 @@ enum ImageSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Image::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Image::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Image::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Image::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Image::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Image::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Image::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Image::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Series;
|
||||
|
||||
enum SeriesSort implements EnumSort
|
||||
@@ -26,20 +26,15 @@ enum SeriesSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Series::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Series::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Series::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Series::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Series::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Series::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Series::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Series::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Series::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Series::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Series::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Series::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Series::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Series::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Series::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Series::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki\Song;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Song\Performance;
|
||||
|
||||
enum PerformanceSort implements EnumSort
|
||||
@@ -34,28 +34,23 @@ enum PerformanceSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Performance::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::ALIAS => new FieldSortCriteria($this, Performance::ATTRIBUTE_ALIAS, isStringField: true),
|
||||
self::ALIAS_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_ALIAS, SortDirection::DESC, isStringField: true),
|
||||
self::AS => new FieldSortCriteria($this, Performance::ATTRIBUTE_AS, isStringField: true),
|
||||
self::AS_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_AS, SortDirection::DESC, isStringField: true),
|
||||
self::MEMBER_ALIAS => new FieldSortCriteria($this, Performance::ATTRIBUTE_MEMBER_ALIAS, isStringField: true),
|
||||
self::MEMBER_ALIAS_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_MEMBER_ALIAS, SortDirection::DESC, isStringField: true),
|
||||
self::MEMBER_AS => new FieldSortCriteria($this, Performance::ATTRIBUTE_MEMBER_AS, isStringField: true),
|
||||
self::MEMBER_AS_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_MEMBER_AS, SortDirection::DESC, isStringField: true),
|
||||
self::RELEVANCE => new FieldSortCriteria($this, Performance::ATTRIBUTE_RELEVANCE),
|
||||
self::RELEVANCE_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_RELEVANCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Performance::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Performance::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Performance::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::ALIAS => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_ALIAS),
|
||||
self::ALIAS_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_ALIAS, SortDirection::DESC),
|
||||
self::AS => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_AS),
|
||||
self::AS_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_AS, SortDirection::DESC),
|
||||
self::MEMBER_ALIAS => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_MEMBER_ALIAS),
|
||||
self::MEMBER_ALIAS_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_MEMBER_ALIAS, SortDirection::DESC),
|
||||
self::MEMBER_AS => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_MEMBER_AS),
|
||||
self::MEMBER_AS_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_MEMBER_AS, SortDirection::DESC),
|
||||
self::RELEVANCE => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_RELEVANCE),
|
||||
self::RELEVANCE_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_RELEVANCE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Performance::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Song;
|
||||
|
||||
enum SongSort implements EnumSort
|
||||
@@ -28,22 +28,17 @@ enum SongSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Song::ATTRIBUTE_ID, SortDirection::ASC),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Song::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::TITLE => new FieldSortCriteria($this, Song::ATTRIBUTE_TITLE, isStringField: true),
|
||||
self::TITLE_DESC => new FieldSortCriteria($this, Song::ATTRIBUTE_TITLE, SortDirection::DESC, isStringField: true),
|
||||
self::TITLE_NATIVE => new FieldSortCriteria($this, Song::ATTRIBUTE_TITLE_NATIVE, isStringField: true),
|
||||
self::TITLE_NATIVE_DESC => new FieldSortCriteria($this, Song::ATTRIBUTE_TITLE_NATIVE, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Song::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Song::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Song::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Song::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Song::ATTRIBUTE_ID, SortDirection::ASC),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Song::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::TITLE => new FieldSortCriteria($this->name, Song::ATTRIBUTE_TITLE),
|
||||
self::TITLE_DESC => new FieldSortCriteria($this->name, Song::ATTRIBUTE_TITLE, SortDirection::DESC),
|
||||
self::TITLE_NATIVE => new FieldSortCriteria($this->name, Song::ATTRIBUTE_TITLE_NATIVE),
|
||||
self::TITLE_NATIVE_DESC => new FieldSortCriteria($this->name, Song::ATTRIBUTE_TITLE_NATIVE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Song::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Song::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Song::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Song::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Studio;
|
||||
|
||||
enum StudioSort implements EnumSort
|
||||
@@ -26,20 +26,15 @@ enum StudioSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Studio::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Studio::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this, Studio::ATTRIBUTE_NAME, isStringField: true),
|
||||
self::NAME_DESC => new FieldSortCriteria($this, Studio::ATTRIBUTE_NAME, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Studio::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Studio::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Studio::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Studio::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Studio::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Synonym;
|
||||
|
||||
enum SynonymSort implements EnumSort
|
||||
@@ -26,20 +26,15 @@ enum SynonymSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Synonym::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Synonym::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::TEXT => new FieldSortCriteria($this, Synonym::ATTRIBUTE_TEXT, isStringField: true),
|
||||
self::TEXT_DESC => new FieldSortCriteria($this, Synonym::ATTRIBUTE_TEXT, SortDirection::DESC, isStringField: true),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Synonym::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Synonym::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Synonym::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Synonym::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::TEXT => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_TEXT),
|
||||
self::TEXT_DESC => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_TEXT, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Synonym::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Group;
|
||||
|
||||
enum ThemeGroupSort implements EnumSort
|
||||
{
|
||||
case ID;
|
||||
case ID_DESC;
|
||||
case NAME;
|
||||
case NAME_DESC;
|
||||
case SLUG;
|
||||
case SLUG_DESC;
|
||||
case CREATED_AT;
|
||||
case CREATED_AT_DESC;
|
||||
case UPDATED_AT;
|
||||
case UPDATED_AT_DESC;
|
||||
case RANDOM;
|
||||
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this->name, Group::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Group::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::NAME => new FieldSortCriteria($this->name, Group::ATTRIBUTE_NAME),
|
||||
self::NAME_DESC => new FieldSortCriteria($this->name, Group::ATTRIBUTE_NAME, SortDirection::DESC),
|
||||
self::SLUG => new FieldSortCriteria($this->name, Group::ATTRIBUTE_SLUG),
|
||||
self::SLUG_DESC => new FieldSortCriteria($this->name, Group::ATTRIBUTE_SLUG, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Group::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Group::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Group::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Group::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ namespace App\Enums\GraphQL\Sort\Wiki;
|
||||
|
||||
use App\Contracts\GraphQL\EnumSort;
|
||||
use App\Enums\GraphQL\SortDirection;
|
||||
use App\GraphQL\Criteria\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Criteria\Sort\SortCriteria;
|
||||
use App\GraphQL\Sort\FieldSortCriteria;
|
||||
use App\GraphQL\Sort\RandomSortCriteria;
|
||||
use App\GraphQL\Sort\SortCriteria;
|
||||
use App\Models\Wiki\Video;
|
||||
|
||||
enum VideoSort implements EnumSort
|
||||
@@ -32,26 +32,21 @@ enum VideoSort implements EnumSort
|
||||
public function getSortCriteria(): SortCriteria
|
||||
{
|
||||
return match ($this) {
|
||||
self::ID => new FieldSortCriteria($this, Video::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::BASENAME => new FieldSortCriteria($this, Video::ATTRIBUTE_BASENAME, isStringField: true),
|
||||
self::BASENAME_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_BASENAME, SortDirection::DESC, isStringField: true),
|
||||
self::FILENAME => new FieldSortCriteria($this, Video::ATTRIBUTE_FILENAME, isStringField: true),
|
||||
self::FILENAME_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_FILENAME, SortDirection::DESC, isStringField: true),
|
||||
self::RESOLUTION => new FieldSortCriteria($this, Video::ATTRIBUTE_RESOLUTION),
|
||||
self::RESOLUTION_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_RESOLUTION, SortDirection::DESC),
|
||||
self::SIZE => new FieldSortCriteria($this, Video::ATTRIBUTE_SIZE),
|
||||
self::SIZE_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_SIZE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this, Video::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this, Video::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this, Video::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this, ''),
|
||||
self::ID => new FieldSortCriteria($this->name, Video::ATTRIBUTE_ID),
|
||||
self::ID_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_ID, SortDirection::DESC),
|
||||
self::BASENAME => new FieldSortCriteria($this->name, Video::ATTRIBUTE_BASENAME),
|
||||
self::BASENAME_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_BASENAME, SortDirection::DESC),
|
||||
self::FILENAME => new FieldSortCriteria($this->name, Video::ATTRIBUTE_FILENAME),
|
||||
self::FILENAME_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_FILENAME, SortDirection::DESC),
|
||||
self::RESOLUTION => new FieldSortCriteria($this->name, Video::ATTRIBUTE_RESOLUTION),
|
||||
self::RESOLUTION_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_RESOLUTION, SortDirection::DESC),
|
||||
self::SIZE => new FieldSortCriteria($this->name, Video::ATTRIBUTE_SIZE),
|
||||
self::SIZE_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_SIZE, SortDirection::DESC),
|
||||
self::CREATED_AT => new FieldSortCriteria($this->name, Video::ATTRIBUTE_CREATED_AT),
|
||||
self::CREATED_AT_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_CREATED_AT, SortDirection::DESC),
|
||||
self::UPDATED_AT => new FieldSortCriteria($this->name, Video::ATTRIBUTE_UPDATED_AT),
|
||||
self::UPDATED_AT_DESC => new FieldSortCriteria($this->name, Video::ATTRIBUTE_UPDATED_AT, SortDirection::DESC),
|
||||
self::RANDOM => new RandomSortCriteria($this->name, ''),
|
||||
};
|
||||
}
|
||||
|
||||
public function shouldQualifyColumn(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ActionLogStatus: int implements HasColor, HasLabel
|
||||
enum ActivityStatus: int implements HasColor, HasLabel
|
||||
{
|
||||
use LocalizesName;
|
||||
|
||||
@@ -25,9 +25,9 @@ enum ActionLogStatus: int implements HasColor, HasLabel
|
||||
public function getColor(): string|array
|
||||
{
|
||||
return match ($this) {
|
||||
ActionLogStatus::RUNNING => Color::Amber,
|
||||
ActionLogStatus::FAILED => 'danger',
|
||||
ActionLogStatus::FINISHED => 'success',
|
||||
ActivityStatus::RUNNING => Color::Amber,
|
||||
ActivityStatus::FAILED => 'danger',
|
||||
ActivityStatus::FINISHED => 'success',
|
||||
};
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user