chore: Laravel 13 (#1135)

This commit is contained in:
Kyrch
2026-03-23 15:31:57 -03:00
committed by GitHub
parent 722aaf9c14
commit fc3f146bb4
181 changed files with 1818 additions and 1808 deletions
+1
View File
@@ -269,6 +269,7 @@ ANILIST_CLIENT_SECRET=null
ANILIST_REDIRECT_URI=null
# session
SESSION_COOKIE=animethemes_session
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_CONNECTION=null
+1
View File
@@ -267,6 +267,7 @@ ANILIST_CLIENT_SECRET=null
ANILIST_REDIRECT_URI=null
# session
SESSION_COOKIE=animethemes_session
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_CONNECTION=null
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Actions\Models\List\External\Entry\Claimed;
use App\Actions\Models\List\External\Entry\BaseExternalEntryClaimedAction;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Models\List\External\ExternalEntry;
use App\Models\Wiki\ExternalResource;
use Illuminate\Http\Client\RequestException;
@@ -37,7 +37,7 @@ class AnilistExternalEntryClaimedAction extends BaseExternalEntryClaimedAction
$entries[] = [
ExternalResource::ATTRIBUTE_EXTERNAL_ID => $entryId,
ExternalEntry::ATTRIBUTE_SCORE => Arr::get($entry, 'score'),
ExternalEntry::ATTRIBUTE_WATCH_STATUS => ExternalEntryWatchStatus::getAnilistMapping(Arr::get($entry, 'status'))->value,
ExternalEntry::ATTRIBUTE_STATUS => ExternalEntryStatus::getAnilistMapping(Arr::get($entry, 'status'))->value,
ExternalEntry::ATTRIBUTE_IS_FAVORITE => Arr::get($entry, 'media.isFavourite'),
];
}
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Actions\Models\List\External\Entry\Claimed;
use App\Actions\Models\List\External\Entry\BaseExternalEntryClaimedAction;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Enums\Models\List\ExternalProfileSite;
use App\Models\List\External\ExternalEntry;
use App\Models\Wiki\ExternalResource;
@@ -42,14 +42,14 @@ class MalExternalEntryClaimedAction extends BaseExternalEntryClaimedAction
$animeInfo = Arr::get($info, 'node');
$listStatus = Arr::get($info, 'list_status');
$watchStatus = Arr::get($listStatus, 'is_rewatching')
$status = Arr::get($listStatus, 'is_rewatching')
? 'rewatching'
: Arr::get($listStatus, 'status');
$entries[] = [
ExternalResource::ATTRIBUTE_EXTERNAL_ID => Arr::get($animeInfo, 'id'),
ExternalEntry::ATTRIBUTE_SCORE => Arr::get($listStatus, 'score'),
ExternalEntry::ATTRIBUTE_WATCH_STATUS => ExternalEntryWatchStatus::getMalMapping($watchStatus)->value,
ExternalEntry::ATTRIBUTE_STATUS => ExternalEntryStatus::getMalMapping($status)->value,
ExternalEntry::ATTRIBUTE_IS_FAVORITE => false,
];
}
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Actions\Models\List\External\Entry\Unclaimed;
use App\Actions\Models\List\External\Entry\BaseExternalEntryUnclaimedAction;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Models\List\External\ExternalEntry;
use App\Models\Wiki\ExternalResource;
use Illuminate\Http\Client\RequestException;
@@ -37,7 +37,7 @@ class AnilistExternalEntryUnclaimedAction extends BaseExternalEntryUnclaimedActi
$entries[] = [
ExternalResource::ATTRIBUTE_EXTERNAL_ID => $entryId,
ExternalEntry::ATTRIBUTE_SCORE => Arr::get($entry, 'score'),
ExternalEntry::ATTRIBUTE_WATCH_STATUS => ExternalEntryWatchStatus::getAnilistMapping(Arr::get($entry, 'status'))->value,
ExternalEntry::ATTRIBUTE_STATUS => ExternalEntryStatus::getAnilistMapping(Arr::get($entry, 'status'))->value,
ExternalEntry::ATTRIBUTE_IS_FAVORITE => in_array($entryId, $favorites),
];
}
@@ -48,7 +48,7 @@ class SyncExternalProfileAction
$externalEntries[] = [
ExternalEntry::ATTRIBUTE_SCORE => Arr::get($entry, ExternalEntry::ATTRIBUTE_SCORE),
ExternalEntry::ATTRIBUTE_IS_FAVORITE => Arr::get($entry, ExternalEntry::ATTRIBUTE_IS_FAVORITE),
ExternalEntry::ATTRIBUTE_WATCH_STATUS => Arr::get($entry, ExternalEntry::ATTRIBUTE_WATCH_STATUS),
ExternalEntry::ATTRIBUTE_STATUS => Arr::get($entry, ExternalEntry::ATTRIBUTE_STATUS),
ExternalEntry::ATTRIBUTE_ANIME => $anime,
ExternalEntry::ATTRIBUTE_PROFILE => $profile->getKey(),
];
@@ -33,7 +33,7 @@ use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class DumpWikiAction extends DumpAction
class DumpContentAction extends DumpAction
{
use ReconcilesDumpRepositories;
@@ -82,7 +82,7 @@ class DumpWikiAction extends DumpAction
$filesystem = Storage::disk('local');
return Str::of($filesystem->path(''))
->append(DumpWikiAction::FILENAME_PREFIX)
->append(DumpContentAction::FILENAME_PREFIX)
->append(strval(Date::now()->valueOf()))
->append('.sql')
->__toString();
@@ -4,12 +4,14 @@ declare(strict_types=1);
namespace App\Console\Commands\Database;
use App\Actions\Storage\Admin\Dump\DumpWikiAction;
use App\Actions\Storage\Admin\Dump\DumpContentAction;
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;
@@ -17,13 +19,13 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Validator as ValidatorFacade;
#[Signature(
'db:sync
{--drop : Determine whether the existing database should be re-created}'
)]
#[Description('Sync the local database with the latest dumps')]
class DatabaseSyncCommand extends BaseCommand
{
protected $signature = 'db:sync
{--drop : Determine whether the existing database should be re-created}';
protected $description = 'Sync the local database with the latest dumps';
public function handle(): int
{
if (app()->isProduction()) {
@@ -45,7 +47,7 @@ class DatabaseSyncCommand extends BaseCommand
if (! $this->option('drop')) {
Schema::withoutForeignKeyConstraints(function (): void {
foreach ([
...DumpWikiAction::allowedTables(),
...DumpContentAction::allowedTables(),
] as $table) {
$this->info("Truncating table {$table}");
DB::table($table)->truncate();
@@ -55,9 +57,9 @@ class DatabaseSyncCommand extends BaseCommand
DB::statement("USE `{$database}`");
$this->info('Importing wiki dump');
$wiki = Http::get('https://dump.animethemes.moe/latest/wiki')->body();
DB::unprepared($wiki);
$this->info('Importing content dump');
$content = Http::get('https://dump.animethemes.moe/latest/content')->body();
DB::unprepared($content);
$this->info('Migrating database');
Artisan::call('migrate');
@@ -6,16 +6,16 @@ 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
{
protected $signature = 'graphql:print-schema {schema=v1}';
protected $description = 'Print the GraphQL schema into SDL';
public function handle(): int
{
$schemaName = $this->argument('schema');
@@ -7,15 +7,15 @@ namespace App\Console\Commands\Models;
use App\Actions\Models\List\Playlist\FixPlaylistAction;
use App\Console\Commands\BaseCommand;
use App\Models\List\Playlist;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Support\Facades\Validator as ValidatorFacade;
#[Signature('playlist:fix {playlistId}')]
#[Description('Fix playlist tracks to remove cycles')]
class PlaylistFixCommand extends BaseCommand
{
protected $signature = 'playlist:fix {playlistId}';
protected $description = 'Fix playlist tracks to remove cycles';
public function handle(): int
{
$playlistId = $this->argument('playlistId');
@@ -6,15 +6,15 @@ namespace App\Console\Commands\Models;
use App\Actions\Models\Aggregate\SyncLikeAggregatesAction;
use App\Console\Commands\BaseCommand;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Support\Facades\Validator as ValidatorFacade;
#[Signature('like:sync-aggregates')]
#[Description('Synchronizes likes in the aggregates table')]
class SyncLikeAggregatesCommand extends BaseCommand
{
protected $signature = 'like:sync-aggregates';
protected $description = 'Synchronizes likes in the aggregates table';
public function handle(): int
{
$action = new SyncLikeAggregatesAction();
@@ -7,16 +7,16 @@ namespace App\Console\Commands\Repositories\Storage\Admin;
use App\Concerns\Repositories\Admin\ReconcilesDumpRepositories;
use App\Console\Commands\Repositories\Storage\StorageReconcileCommand;
use App\Constants\Config\DumpConstants;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Support\Facades\Config;
#[Signature('reconcile:dump')]
#[Description('Perform set reconciliation between object storage and dump database')]
class DumpReconcileCommand extends StorageReconcileCommand
{
use ReconcilesDumpRepositories;
protected $signature = 'reconcile:dump';
protected $description = 'Perform set reconciliation between object storage and dump database';
public function disk(): string
{
return Config::get(DumpConstants::DISK_QUALIFIED);
@@ -7,17 +7,19 @@ namespace App\Console\Commands\Repositories\Storage\Wiki;
use App\Concerns\Repositories\Wiki\ReconcilesAudioRepositories;
use App\Console\Commands\Repositories\Storage\StorageReconcileCommand;
use App\Constants\Config\AudioConstants;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Support\Facades\Config;
#[Signature(
'reconcile:audio
{--path= : The directory of audios to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}'
)]
#[Description('Perform set reconciliation between object storage and audios database')]
class AudioReconcileCommand extends StorageReconcileCommand
{
use ReconcilesAudioRepositories;
protected $signature = 'reconcile:audio
{--path= : The directory of audios to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}';
protected $description = 'Perform set reconciliation between object storage and audios database';
public function disk(): string
{
return Config::get(AudioConstants::DEFAULT_DISK_QUALIFIED);
@@ -7,17 +7,19 @@ namespace App\Console\Commands\Repositories\Storage\Wiki\Video;
use App\Concerns\Repositories\Wiki\Video\ReconcilesScriptRepositories;
use App\Console\Commands\Repositories\Storage\StorageReconcileCommand;
use App\Constants\Config\VideoConstants;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Support\Facades\Config;
#[Signature(
'reconcile:script
{--path= : The directory of scripts to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}'
)]
#[Description('Perform set reconciliation between object storage and script database')]
class ScriptReconcileCommand extends StorageReconcileCommand
{
use ReconcilesScriptRepositories;
protected $signature = 'reconcile:script
{--path= : The directory of scripts to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}';
protected $description = 'Perform set reconciliation between object storage and script database';
public function disk(): string
{
return Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED);
@@ -7,17 +7,19 @@ namespace App\Console\Commands\Repositories\Storage\Wiki;
use App\Concerns\Repositories\Wiki\ReconcilesVideoRepositories;
use App\Console\Commands\Repositories\Storage\StorageReconcileCommand;
use App\Constants\Config\VideoConstants;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Support\Facades\Config;
#[Signature(
'reconcile:video
{--path= : The directory of videos to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}'
)]
#[Description('Perform set reconciliation between object storage and video database')]
class VideoReconcileCommand extends StorageReconcileCommand
{
use ReconcilesVideoRepositories;
protected $signature = 'reconcile:video
{--path= : The directory of videos to reconcile. Ex: 2022/Spring/. If unspecified, all directories will be listed.}';
protected $description = 'Perform set reconciliation between object storage and video database';
public function disk(): string
{
return Config::get(VideoConstants::DEFAULT_DISK_QUALIFIED);
@@ -5,29 +5,30 @@ declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpAdminAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-admin
{--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 admin-related tables for seeding purposes')]
class AdminDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-admin
{--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}
';
protected $description = 'Produces sanitized database dump, targeting admin-related tables for seeding purposes';
protected function action(): DumpAdminAction
{
return new DumpAdminAction($this->options());
@@ -5,29 +5,30 @@ declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpAuthAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-auth
{--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 auth-related tables for seeding purposes')]
class AuthDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-auth
{--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}
';
protected $description = 'Produces sanitized database dump, targeting auth-related tables for seeding purposes';
protected function action(): DumpAuthAction
{
return new DumpAuthAction($this->options());
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpContentAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-content
{--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 content-related tables for seeding purposes')]
class ContentDumpCommand extends DumpCommand
{
protected function action(): DumpContentAction
{
return new DumpContentAction($this->options());
}
}
@@ -5,29 +5,30 @@ 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 $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}
';
protected $description = 'Produces sanitized database dump, targeting discord-related tables for seeding purposes';
protected function action(): DumpDiscordAction
{
return new DumpDiscordAction($this->options());
@@ -5,29 +5,30 @@ declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpDocumentAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-document
{--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 document-related tables for seeding purposes')]
class DocumentDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-document
{--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}
';
protected $description = 'Produces sanitized database dump, targeting document-related tables for seeding purposes';
protected function action(): DumpDocumentAction
{
return new DumpDocumentAction($this->options());
@@ -7,11 +7,11 @@ namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\PruneDumpAction;
use App\Actions\Storage\Base\PruneAction;
use App\Console\Commands\Storage\Base\PruneCommand;
use Illuminate\Console\Attributes\Signature;
#[Signature('prune:dump {--H|hours=72 : The number of hours to retain dumps}')]
class DumpPruneCommand extends PruneCommand
{
protected $signature = 'prune:dump {--H|hours=72 : The number of hours to retain dumps}';
protected function getAction(): PruneAction
{
$hours = $this->option('hours');
@@ -5,29 +5,30 @@ declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpListAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-list
{--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 list-related tables for seeding purposes')]
class ListDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-list
{--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}
';
protected $description = 'Produces sanitized database dump, targeting list-related tables for seeding purposes';
protected function action(): DumpListAction
{
return new DumpListAction($this->options());
@@ -5,29 +5,30 @@ declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpUserAction;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
#[Signature(
'db:dump-user
{--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 user-related tables for seeding purposes')]
class UserDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-user
{--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}
';
protected $description = 'Produces sanitized database dump, targeting user-related tables for seeding purposes';
protected function action(): DumpUserAction
{
return new DumpUserAction($this->options());
@@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpWikiAction;
class WikiDumpCommand extends DumpCommand
{
protected $signature = 'db:dump-wiki
{--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}
';
protected $description = 'Produces sanitized database dump, targeting wiki-related tables for seeding purposes';
protected function action(): DumpWikiAction
{
return new DumpWikiAction($this->options());
}
}
+2 -2
View File
@@ -8,12 +8,12 @@ use App\Console\Commands\Models\SyncLikeAggregatesCommand;
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;
use App\Console\Commands\Storage\Admin\UserDumpCommand;
use App\Console\Commands\Storage\Admin\WikiDumpCommand;
use App\Models\BaseModel;
use Illuminate\Auth\Console\ClearResetsCommand;
use Illuminate\Cache\Console\PruneStaleTagsCommand;
@@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel
->storeOutput()
->everyFifteenMinutes();
$schedule->command(WikiDumpCommand::class)
$schedule->command(ContentDumpCommand::class)
->withoutOverlapping()
->runInBackground()
->storeOutput()
@@ -7,7 +7,7 @@ namespace App\Enums\Models\List;
use App\Concerns\Enums\LocalizesName;
use Filament\Support\Contracts\HasLabel;
enum ExternalEntryWatchStatus: int implements HasLabel
enum ExternalEntryStatus: int implements HasLabel
{
use LocalizesName;
@@ -19,7 +19,7 @@ enum ExternalEntryWatchStatus: int implements HasLabel
case REWATCHING = 5;
/**
* Get the watch status by the MAL key.
* Get the status by the MAL key.
*/
public static function getMalMapping(string $status): static
{
@@ -34,7 +34,7 @@ enum ExternalEntryWatchStatus: int implements HasLabel
}
/**
* Get the watch status by the AniList key.
* Get the status by the AniList key.
*/
public static function getAnilistMapping(string $status): static
{
@@ -5,20 +5,20 @@ declare(strict_types=1);
namespace App\Filament\Actions\Storage\Admin;
use App\Actions\Storage\Admin\Dump\DumpAction as DumpDatabase;
use App\Actions\Storage\Admin\Dump\DumpWikiAction as DumpWikiDatabase;
use App\Actions\Storage\Admin\Dump\DumpContentAction as DumpContentDatabase;
class DumpWikiAction extends DumpAction
class DumpContentAction extends DumpAction
{
public static function getDefaultName(): ?string
{
return 'dump-wiki';
return 'dump-content';
}
protected function setUp(): void
{
parent::setUp();
$this->label(__('filament.actions.dump.dump.name.wiki'));
$this->label(__('filament.actions.dump.dump.name.content'));
}
/**
@@ -26,6 +26,6 @@ class DumpWikiAction extends DumpAction
*/
protected function storageAction(array $data): DumpDatabase
{
return new DumpWikiDatabase($data);
return new DumpContentDatabase($data);
}
}
@@ -7,8 +7,8 @@ namespace App\Filament\Resources\Admin;
use App\Enums\Filament\NavigationGroup;
use App\Filament\Actions\Repositories\Storage\Admin\Dump\ReconcileDumpAction;
use App\Filament\Actions\Storage\Admin\DownloadDumpAction;
use App\Filament\Actions\Storage\Admin\DumpContentAction;
use App\Filament\Actions\Storage\Admin\DumpDocumentAction;
use App\Filament\Actions\Storage\Admin\DumpWikiAction;
use App\Filament\Actions\Storage\Admin\PruneDumpAction;
use App\Filament\Components\Columns\TextColumn;
use App\Filament\Components\Fields\TextInput;
@@ -137,7 +137,7 @@ class DumpResource extends BaseResource
{
return [
ActionGroup::make([
DumpWikiAction::make(),
DumpContentAction::make(),
DumpDocumentAction::make(),
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Filament\Resources\List\External;
use App\Enums\Filament\NavigationGroup;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Filament\Components\Columns\BelongsToColumn;
use App\Filament\Components\Columns\TextColumn;
use App\Filament\Components\Fields\BelongsTo;
@@ -99,10 +99,10 @@ class ExternalEntryResource extends BaseResource
->helperText(__('filament.fields.external_entry.score.help'))
->numeric(),
Select::make(ExternalEntry::ATTRIBUTE_WATCH_STATUS)
->label(__('filament.fields.external_entry.watch_status.name'))
->helperText(__('filament.fields.external_entry.watch_status.help'))
->options(ExternalEntryWatchStatus::class)
Select::make(ExternalEntry::ATTRIBUTE_STATUS)
->label(__('filament.fields.external_entry.status.name'))
->helperText(__('filament.fields.external_entry.status.help'))
->options(ExternalEntryStatus::class)
->required(),
Checkbox::make(ExternalEntry::ATTRIBUTE_IS_FAVORITE)
@@ -127,9 +127,9 @@ class ExternalEntryResource extends BaseResource
TextColumn::make(ExternalEntry::ATTRIBUTE_SCORE)
->label(__('filament.fields.external_entry.score.name')),
TextColumn::make(ExternalEntry::ATTRIBUTE_WATCH_STATUS)
->label(__('filament.fields.external_entry.watch_status.name'))
->formatStateUsing(fn (ExternalEntryWatchStatus $state): ?string => $state->localize()),
TextColumn::make(ExternalEntry::ATTRIBUTE_STATUS)
->label(__('filament.fields.external_entry.status.name'))
->formatStateUsing(fn (ExternalEntryStatus $state): ?string => $state->localize()),
TextColumn::make(ExternalEntry::ATTRIBUTE_ID)
->label(__('filament.fields.base.id')),
@@ -152,9 +152,9 @@ class ExternalEntryResource extends BaseResource
TextEntry::make(ExternalEntry::ATTRIBUTE_SCORE)
->label(__('filament.fields.external_entry.score.name')),
TextEntry::make(ExternalEntry::ATTRIBUTE_WATCH_STATUS)
->label(__('filament.fields.external_entry.watch_status.name'))
->formatStateUsing(fn (ExternalEntryWatchStatus $state): ?string => $state->localize()),
TextEntry::make(ExternalEntry::ATTRIBUTE_STATUS)
->label(__('filament.fields.external_entry.status.name'))
->formatStateUsing(fn (ExternalEntryStatus $state): ?string => $state->localize()),
TextEntry::make(ExternalEntry::ATTRIBUTE_ID)
->label(__('filament.fields.base.id')),
@@ -179,8 +179,8 @@ class ExternalEntryResource extends BaseResource
NumberConstraint::make(ExternalEntry::ATTRIBUTE_SCORE)
->label(__('filament.fields.external_entry.score.name')),
SelectConstraint::make(ExternalEntry::ATTRIBUTE_WATCH_STATUS)
->label(__('filament.fields.external_entry.watch_status.name'))
SelectConstraint::make(ExternalEntry::ATTRIBUTE_STATUS)
->label(__('filament.fields.external_entry.status.name'))
->multiple(),
...parent::getConstraints(),
+1 -1
View File
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\Auth;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\Auth\User;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class UserChart extends BaseChartWidget
{
+1 -1
View File
@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Filament\Widgets;
use App\Services\FlowframeTrend\Trend;
use Elemind\FilamentECharts\Widgets\EChartWidget;
use Flowframe\Trend\Trend;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\List;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\List\ExternalProfile;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class ExternalProfileChart extends BaseChartWidget
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\List;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\List\Playlist;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class PlaylistChart extends BaseChartWidget
{
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\List;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\List\Playlist\PlaylistTrack;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class PlaylistTrackChart extends BaseChartWidget
{
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\Wiki\Anime;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\Wiki\Anime;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class AnimeChart extends BaseChartWidget
{
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\Wiki\Artist;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\Wiki\Artist;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class ArtistChart extends BaseChartWidget
{
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\Wiki\Series;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\Wiki\Series;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class SeriesChart extends BaseChartWidget
{
@@ -6,7 +6,7 @@ namespace App\Filament\Widgets\Wiki\Video;
use App\Filament\Widgets\BaseChartWidget;
use App\Models\Wiki\Video;
use Flowframe\Trend\TrendValue;
use App\Services\FlowframeTrend\TrendValue;
class VideoChart extends BaseChartWidget
{
@@ -4,19 +4,19 @@ declare(strict_types=1);
namespace App\GraphQL\Schema\Fields\List\ExternalProfile\ExternalEntry;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\GraphQL\Schema\Fields\EnumField;
use App\Models\List\External\ExternalEntry;
class ExternalEntryWatchStatusField extends EnumField
class ExternalEntryStatusField extends EnumField
{
public function __construct()
{
parent::__construct(ExternalEntry::ATTRIBUTE_WATCH_STATUS, ExternalEntryWatchStatus::class, nullable: false);
parent::__construct(ExternalEntry::ATTRIBUTE_STATUS, ExternalEntryStatus::class, nullable: false);
}
public function description(): string
{
return 'The watch status of the entry on the external site';
return 'The status of the entry on the external site';
}
}
@@ -10,7 +10,7 @@ use App\GraphQL\Schema\Fields\Base\UpdatedAtField;
use App\GraphQL\Schema\Fields\Field;
use App\GraphQL\Schema\Fields\List\ExternalProfile\ExternalEntry\ExternalEntryIsFavoriteField;
use App\GraphQL\Schema\Fields\List\ExternalProfile\ExternalEntry\ExternalEntryScoreField;
use App\GraphQL\Schema\Fields\List\ExternalProfile\ExternalEntry\ExternalEntryWatchStatusField;
use App\GraphQL\Schema\Fields\List\ExternalProfile\ExternalEntry\ExternalEntryStatusField;
use App\GraphQL\Schema\Fields\LocalizedEnumField;
use App\GraphQL\Schema\Fields\Relations\BelongsToRelation;
use App\GraphQL\Schema\Types\EloquentType;
@@ -36,8 +36,8 @@ class ExternalEntryType extends EloquentType
new IdField(ExternalEntry::ATTRIBUTE_ID, ExternalEntry::class),
new ExternalEntryScoreField(),
new ExternalEntryIsFavoriteField(),
new ExternalEntryWatchStatusField(),
new LocalizedEnumField(new ExternalEntryWatchStatusField()),
new ExternalEntryStatusField(),
new LocalizedEnumField(new ExternalEntryStatusField()),
new CreatedAtField(),
new UpdatedAtField(),
@@ -6,25 +6,25 @@ namespace App\Http\Api\Field\List\ExternalProfile\ExternalEntry;
use App\Contracts\Http\Api\Field\CreatableField;
use App\Contracts\Http\Api\Field\UpdatableField;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Http\Api\Field\EnumField;
use App\Http\Api\Schema\Schema;
use App\Models\List\External\ExternalEntry;
use Illuminate\Http\Request;
use Illuminate\Validation\Rules\Enum;
class ExternalEntryWatchStatusField extends EnumField implements CreatableField, UpdatableField
class ExternalEntryStatusField extends EnumField implements CreatableField, UpdatableField
{
public function __construct(Schema $schema)
{
parent::__construct($schema, ExternalEntry::ATTRIBUTE_WATCH_STATUS, ExternalEntryWatchStatus::class);
parent::__construct($schema, ExternalEntry::ATTRIBUTE_STATUS, ExternalEntryStatus::class);
}
public function getCreationRules(Request $request): array
{
return [
'required',
new Enum(ExternalEntryWatchStatus::class),
new Enum(ExternalEntryStatus::class),
];
}
@@ -33,7 +33,7 @@ class ExternalEntryWatchStatusField extends EnumField implements CreatableField,
return [
'sometimes',
'required',
new Enum(ExternalEntryWatchStatus::class),
new Enum(ExternalEntryStatus::class),
];
}
}
+2 -2
View File
@@ -12,7 +12,7 @@ use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryAnimeIdFi
use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryExternalProfileIdField;
use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryIsFavoriteField;
use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryScoreField;
use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryWatchStatusField;
use App\Http\Api\Field\List\ExternalProfile\ExternalEntry\ExternalEntryStatusField;
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Auth\UserSchema;
use App\Http\Api\Schema\EloquentSchema;
@@ -51,7 +51,7 @@ class ExternalEntrySchema extends EloquentSchema
new IdField($this, ExternalEntry::ATTRIBUTE_ID),
new ExternalEntryScoreField($this),
new ExternalEntryIsFavoriteField($this),
new ExternalEntryWatchStatusField($this),
new ExternalEntryStatusField($this),
new ExternalEntryAnimeIdField($this),
new ExternalEntryExternalProfileIdField($this),
];
@@ -5,14 +5,14 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin;
use App\Actions\Http\Admin\Dump\DumpDownloadAction;
use App\Actions\Storage\Admin\Dump\DumpWikiAction;
use App\Actions\Storage\Admin\Dump\DumpContentAction;
use App\Enums\Http\Api\Filter\ComparisonOperator;
use App\Http\Controllers\Controller;
use App\Models\Admin\Dump;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpFoundation\StreamedResponse;
class LatestWikiDumpController extends Controller
class LatestContentDumpController extends Controller
{
/**
* Download dump.
@@ -23,7 +23,7 @@ class LatestWikiDumpController extends Controller
{
/** @var Dump $dump */
$dump = Dump::query()
->where(Dump::ATTRIBUTE_PATH, ComparisonOperator::LIKE->value, DumpWikiAction::FILENAME_PREFIX.'%')
->where(Dump::ATTRIBUTE_PATH, ComparisonOperator::LIKE->value, DumpContentAction::FILENAME_PREFIX.'%')
->latest()
->firstOrFail();
@@ -7,14 +7,13 @@ namespace App\Http\Controllers\Api\Auth\User\Me\List;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\List\ExternalProfileSchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Middleware\Auth\Authenticate;
use App\Http\Requests\Api\IndexRequest;
use App\Http\Resources\List\Collection\ExternalProfileCollection;
use App\Models\Auth\User;
use App\Models\List\ExternalProfile;
use Illuminate\Support\Facades\Auth;
use Illuminate\Container\Attributes\CurrentUser;
class MyExternalProfileController extends BaseController
{
@@ -24,13 +23,10 @@ class MyExternalProfileController extends BaseController
parent::__construct(ExternalProfile::class, 'externalprofile');
}
public function index(IndexRequest $request, IndexAction $action): ExternalProfileCollection
public function index(IndexRequest $request, #[CurrentUser] User $user, IndexAction $action): ExternalProfileCollection
{
$query = new Query($request->validated());
/** @var User $user */
$user = Auth::user();
$builder = $user->externalprofiles()->getQuery();
$profiles = $action->index($builder, $query, $request->schema());
@@ -6,7 +6,6 @@ namespace App\Http\Controllers\Api\Auth\User\Me\List;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\Schema;
use App\Http\Api\Schema\User\NotificationSchema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Middleware\Auth\Authenticate;
@@ -14,6 +13,7 @@ use App\Http\Requests\Api\IndexRequest;
use App\Http\Resources\User\Collection\NotificationCollection;
use App\Models\Auth\User;
use App\Models\User\Notification;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
@@ -25,13 +25,10 @@ class MyNotificationController extends BaseController
parent::__construct(Notification::class, 'notification');
}
public function index(IndexRequest $request, IndexAction $action): NotificationCollection
public function index(IndexRequest $request, #[CurrentUser] User $user, IndexAction $action): NotificationCollection
{
$query = new Query($request->validated());
/** @var User $user */
$user = Auth::user();
$builder = $user->notifications()->getQuery();
$notifications = $action->index($builder, $query, $request->schema());
@@ -7,14 +7,13 @@ namespace App\Http\Controllers\Api\Auth\User\Me\List;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\List\PlaylistSchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Middleware\Auth\Authenticate;
use App\Http\Requests\Api\IndexRequest;
use App\Http\Resources\List\Collection\PlaylistCollection;
use App\Models\Auth\User;
use App\Models\List\Playlist;
use Illuminate\Support\Facades\Auth;
use Illuminate\Container\Attributes\CurrentUser;
class MyPlaylistController extends BaseController
{
@@ -24,13 +23,10 @@ class MyPlaylistController extends BaseController
parent::__construct(Playlist::class, 'playlist');
}
public function index(IndexRequest $request, IndexAction $action): PlaylistCollection
public function index(IndexRequest $request, #[CurrentUser] User $user, IndexAction $action): PlaylistCollection
{
$query = new Query($request->validated());
/** @var User $user */
$user = Auth::user();
$builder = $user->playlists()->getQuery();
$playlists = $action->index($builder, $query, $request->schema());
@@ -7,13 +7,12 @@ namespace App\Http\Controllers\Api\Auth\User\Me;
use App\Actions\Http\Api\ShowAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\Auth\User\MySchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Middleware\Auth\Authenticate;
use App\Http\Requests\Api\ShowRequest;
use App\Http\Resources\Auth\User\Resource\MyJsonResource;
use App\Models\Auth\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Container\Attributes\CurrentUser;
class MyController extends BaseController
{
@@ -25,13 +24,10 @@ class MyController extends BaseController
$this->middleware(Authenticate::using('sanctum'));
}
public function show(ShowRequest $request, ShowAction $action): MyJsonResource
public function show(ShowRequest $request, #[CurrentUser] User $user, ShowAction $action): MyJsonResource
{
$query = new Query($request->validated());
/** @var User $user */
$user = Auth::user();
$show = $action->show($user, $query, $request->schema());
return new MyJsonResource($show, $query);
@@ -24,7 +24,6 @@ use App\Http\Resources\List\Resource\ExternalProfileJsonResource;
use App\Models\List\ExternalProfile;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class ExternalProfileController extends BaseController
@@ -33,13 +32,8 @@ class ExternalProfileController extends BaseController
{
parent::__construct(ExternalProfile::class, 'externalprofile');
$isExternalProfileManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowExternalProfileManagement::class)
->__toString();
$this->middleware(EnabledOnlyOnLocalhost::class);
$this->middleware($isExternalProfileManagementAllowed)->except(['index', 'show']);
$this->middleware(EnsureFeaturesAreActive::using(AllowExternalProfileManagement::class))->except(['index', 'show']);
$this->middleware(UserExceedsExternalProfileLimit::class)->only(['store', 'restore']);
}
@@ -49,9 +43,9 @@ class ExternalProfileController extends BaseController
$builder = ExternalProfile::query()->where(ExternalProfile::ATTRIBUTE_VISIBILITY, ExternalProfileVisibility::PUBLIC->value);
$userId = Auth::id();
if ($userId) {
$builder->orWhereBelongsTo(Auth::user());
$user = Auth::user();
if ($user) {
$builder->orWhereBelongsTo($user);
}
$externalprofiles = $query->hasSearchCriteria()
@@ -7,7 +7,6 @@ namespace App\Http\Controllers\Api\List\Playlist;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\List\Playlist\ForwardBackwardSchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Requests\Api\List\Playlist\ForwardBackwardIndexRequest;
use App\Http\Resources\List\Playlist\Collection\TrackCollection;
@@ -23,7 +23,6 @@ use App\Models\List\Playlist;
use App\Models\List\Playlist\PlaylistTrack;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class TrackController extends BaseController
@@ -32,12 +31,7 @@ class TrackController extends BaseController
{
parent::__construct(PlaylistTrack::class, 'track,playlist');
$isPlaylistManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowPlaylistManagement::class)
->__toString();
$this->middleware($isPlaylistManagementAllowed)->except(['index', 'show']);
$this->middleware(EnsureFeaturesAreActive::using(AllowPlaylistManagement::class))->except(['index', 'show']);
$this->middleware(PlaylistExceedsTrackLimit::class)->only(['store', 'restore']);
}
@@ -7,7 +7,6 @@ namespace App\Http\Controllers\Api\List\Playlist;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\List\Playlist\ForwardBackwardSchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Requests\Api\List\Playlist\ForwardBackwardIndexRequest;
use App\Http\Resources\List\Playlist\Collection\TrackCollection;
@@ -23,7 +23,6 @@ use App\Http\Resources\List\Resource\PlaylistJsonResource;
use App\Models\List\Playlist;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class PlaylistController extends BaseController
@@ -32,12 +31,7 @@ class PlaylistController extends BaseController
{
parent::__construct(Playlist::class, 'playlist');
$isPlaylistManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowPlaylistManagement::class)
->__toString();
$this->middleware($isPlaylistManagementAllowed)->except(['index', 'show']);
$this->middleware(EnsureFeaturesAreActive::using(AllowPlaylistManagement::class))->except(['index', 'show']);
$this->middleware(UserExceedsPlaylistLimit::class)->only(['store', 'restore']);
}
@@ -7,7 +7,6 @@ namespace App\Http\Controllers\Api\List;
use App\Actions\Http\Api\IndexAction;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\List\Playlist\ForwardBackwardSchema;
use App\Http\Api\Schema\Schema;
use App\Http\Controllers\Api\BaseController;
use App\Http\Requests\Api\List\Playlist\ForwardBackwardIndexRequest;
use App\Http\Resources\List\Playlist\Collection\TrackCollection;
@@ -11,20 +11,14 @@ use App\Http\Middleware\Api\EnabledOnlyOnLocalhost;
use App\Http\Requests\List\External\ExternalTokenAuthRequest;
use App\Models\List\ExternalProfile;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class ExternalTokenAuthController extends Controller
{
public function __construct()
{
$isExternalProfileManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowExternalProfileManagement::class)
->__toString();
$this->middleware(EnabledOnlyOnLocalhost::class);
$this->middleware($isExternalProfileManagementAllowed);
$this->middleware(EnsureFeaturesAreActive::using(AllowExternalProfileManagement::class));
}
/**
@@ -12,20 +12,14 @@ use App\Http\Requests\List\External\ExternalTokenCallbackRequest;
use App\Models\List\ExternalProfile;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class ExternalTokenCallbackController extends Controller
{
public function __construct()
{
$isExternalProfileManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowExternalProfileManagement::class)
->__toString();
$this->middleware(EnabledOnlyOnLocalhost::class);
$this->middleware($isExternalProfileManagementAllowed);
$this->middleware(EnsureFeaturesAreActive::using(AllowExternalProfileManagement::class));
}
/**
@@ -11,21 +11,15 @@ use App\Http\Middleware\Models\List\ExternalProfileSyncLimit;
use App\Http\Requests\Api\ShowRequest;
use App\Models\List\ExternalProfile;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Str;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
class SyncExternalProfileController extends Controller
{
public function __construct()
{
$isExternalProfileManagementAllowed = Str::of(EnsureFeaturesAreActive::class)
->append(':')
->append(AllowExternalProfileManagement::class)
->__toString();
$this->authorizeResource(ExternalProfile::class, 'externalprofile');
$this->middleware(EnabledOnlyOnLocalhost::class);
$this->middleware($isExternalProfileManagementAllowed)->except(['show']);
$this->middleware(EnsureFeaturesAreActive::using(AllowExternalProfileManagement::class))->except(['show']);
$this->middleware(ExternalProfileSyncLimit::class)->only('update');
}
+3 -3
View File
@@ -25,9 +25,9 @@ use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Http\Middleware\HandleCors;
use Illuminate\Http\Middleware\SetCacheHeaders;
use Illuminate\Routing\Middleware\SubstituteBindings;
@@ -68,7 +68,7 @@ class Kernel extends HttpKernel
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
PreventRequestForgery::class,
SubstituteBindings::class,
LogRequest::class,
],
@@ -78,7 +78,7 @@ class Kernel extends HttpKernel
AddQueuedCookiesToResponse::class,
StartSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
PreventRequestForgery::class,
SubstituteBindings::class,
LogRequest::class,
'auth',
+4 -8
View File
@@ -12,12 +12,15 @@ use DateTime;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Attributes\Backoff;
use Illuminate\Queue\Attributes\DeleteWhenMissingModels;
use Illuminate\Queue\Attributes\WithoutRelations;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Support\Facades\Date;
use Laravel\Pennant\Feature;
#[Backoff(120)]
#[DeleteWhenMissingModels]
#[WithoutRelations]
class SyncExternalProfileJob implements ShouldQueue
@@ -26,13 +29,6 @@ class SyncExternalProfileJob implements ShouldQueue
use InteractsWithQueue;
use Queueable;
/**
* The number of seconds to wait before retrying the queued listener.
*
* @var int
*/
public $backoff = 120;
public function __construct(public readonly ExternalProfile $profile)
{
$this->onQueue("sync-external-profile-{$profile->site->name}");
@@ -60,6 +56,6 @@ class SyncExternalProfileJob implements ShouldQueue
*/
public function retryUntil(): DateTime
{
return now()->addMinutes(15);
return Date::now()->addMinutes(15);
}
}
+4 -8
View File
@@ -12,11 +12,14 @@ use DateTime;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Attributes\Backoff;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Notification;
use Laravel\Pennant\Feature;
#[Backoff(60)]
class SendDiscordNotificationJob implements ShouldQueue
{
use Dispatchable;
@@ -24,13 +27,6 @@ class SendDiscordNotificationJob implements ShouldQueue
use Queueable;
use SerializesModels;
/**
* The number of seconds to wait before retrying the queued listener.
*
* @var int
*/
public $backoff = 60;
public function __construct(protected readonly DiscordMessageEvent $event) {}
public function handle(): void
@@ -51,6 +47,6 @@ class SendDiscordNotificationJob implements ShouldQueue
*/
public function retryUntil(): DateTime
{
return now()->addMinutes(15);
return Date::now()->addMinutes(15);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ class LogQueueBusy
public function handle(QueueBusy $event): void
{
Log::info('QueueBusy', [
'connection' => $event->connection,
'connection' => $event->connectionName,
'remember' => $event->queue,
'size' => $event->size,
]);
+2 -14
View File
@@ -14,6 +14,7 @@ use App\Observers\Admin\ActionLogObserver;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -43,6 +44,7 @@ use Throwable;
* @property User|null $user
*/
#[ObservedBy(ActionLogObserver::class)]
#[Table(ActionLog::TABLE, ActionLog::ATTRIBUTE_ID)]
class ActionLog extends Model implements Nameable
{
final public const string TABLE = 'action_logs';
@@ -71,20 +73,6 @@ class ActionLog extends Model implements Nameable
final public const string RELATION_USER = 'user';
final public const string RELATION_TARGET = 'target';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ActionLog::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = ActionLog::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
+3 -14
View File
@@ -10,6 +10,7 @@ use App\Events\Admin\Announcement\AnnouncementUpdated;
use App\Models\BaseModel;
use Database\Factories\Admin\AnnouncementFactory;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Carbon;
@@ -26,6 +27,7 @@ use OwenIt\Auditing\Contracts\Auditable;
* @method static AnnouncementFactory factory(...$parameters)
* @method static Builder<static> current()
*/
#[Table(Announcement::TABLE, Announcement::ATTRIBUTE_ID)]
class Announcement extends BaseModel implements Auditable
{
use HasAudits;
@@ -38,20 +40,6 @@ class Announcement extends BaseModel implements Auditable
final public const string ATTRIBUTE_ID = 'announcement_id';
final public const string ATTRIBUTE_START_AT = 'start_at';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Announcement::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Announcement::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -84,6 +72,7 @@ class Announcement extends BaseModel implements Auditable
protected function casts(): array
{
return [
Announcement::ATTRIBUTE_CONTENT => 'string',
Announcement::ATTRIBUTE_END_AT => 'datetime',
Announcement::ATTRIBUTE_START_AT => 'datetime',
];
+5 -23
View File
@@ -9,7 +9,9 @@ use App\Events\Admin\Dump\DumpDeleted;
use App\Events\Admin\Dump\DumpUpdated;
use App\Models\BaseModel;
use Database\Factories\Admin\DumpFactory;
use Illuminate\Database\Eloquent\Attributes\Appends;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -22,6 +24,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
* @method static DumpFactory factory(...$parameters)
* @method static Builder public()
*/
#[Appends([Dump::ATTRIBUTE_LINK])]
#[Table(Dump::TABLE, Dump::ATTRIBUTE_ID)]
class Dump extends BaseModel
{
use HasFactory;
@@ -33,20 +37,6 @@ class Dump extends BaseModel
final public const string ATTRIBUTE_PUBLIC = 'public';
final public const string ATTRIBUTE_LINK = 'link';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Dump::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Dump::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -70,15 +60,6 @@ class Dump extends BaseModel
Dump::ATTRIBUTE_PUBLIC,
];
/**
* The accessors to append to the model's array form.
*
* @var list<string>
*/
protected $appends = [
Dump::ATTRIBUTE_LINK,
];
/**
* Get the attributes that should be cast.
*
@@ -87,6 +68,7 @@ class Dump extends BaseModel
protected function casts(): array
{
return [
Dump::ATTRIBUTE_PATH => 'string',
Dump::ATTRIBUTE_PUBLIC => 'bool',
];
}
+16 -14
View File
@@ -10,6 +10,7 @@ use App\Events\Admin\Feature\FeatureDeleted;
use App\Events\Admin\Feature\FeatureUpdated;
use App\Models\BaseModel;
use Database\Factories\Admin\FeatureFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Carbon;
@@ -23,6 +24,7 @@ use Illuminate\Support\Carbon;
*
* @method static FeatureFactory factory(...$parameters)
*/
#[Table(Feature::TABLE, Feature::ATTRIBUTE_ID)]
class Feature extends BaseModel
{
use HasFactory;
@@ -34,20 +36,6 @@ class Feature extends BaseModel
final public const string ATTRIBUTE_SCOPE = 'scope';
final public const string ATTRIBUTE_VALUE = 'value';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Feature::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Feature::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -70,6 +58,20 @@ class Feature extends BaseModel
Feature::ATTRIBUTE_VALUE,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Feature::ATTRIBUTE_NAME => 'string',
Feature::ATTRIBUTE_SCOPE => 'string',
Feature::ATTRIBUTE_VALUE => 'string',
];
}
public function getName(): string
{
return $this->name;
+5 -14
View File
@@ -13,6 +13,7 @@ use App\Models\BaseModel;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Video;
use Database\Factories\Admin\FeaturedThemeFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
@@ -33,6 +34,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static FeaturedThemeFactory factory(...$parameters)
*/
#[Table(FeaturedTheme::TABLE, FeaturedTheme::ATTRIBUTE_ID)]
class FeaturedTheme extends BaseModel implements Auditable
{
use HasAudits;
@@ -57,20 +59,6 @@ class FeaturedTheme extends BaseModel implements Auditable
final public const string RELATION_USER = 'user';
final public const string RELATION_VIDEO = 'video';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = FeaturedTheme::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = FeaturedTheme::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -106,7 +94,10 @@ class FeaturedTheme extends BaseModel implements Auditable
{
return [
FeaturedTheme::ATTRIBUTE_END_AT => 'datetime',
FeaturedTheme::ATTRIBUTE_ENTRY => 'int',
FeaturedTheme::ATTRIBUTE_START_AT => 'datetime',
FeaturedTheme::ATTRIBUTE_USER => 'int',
FeaturedTheme::ATTRIBUTE_VIDEO => 'int',
];
}
+12 -17
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Models\Aggregate;
use App\Contracts\Models\Likeable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -14,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
* @property int $likeable_id
* @property int $value
*/
#[Table(LikeAggregate::TABLE, incrementing: false, timestamps: false)]
class LikeAggregate extends Model
{
final public const string TABLE = 'like_aggregates';
@@ -24,25 +26,18 @@ class LikeAggregate extends Model
final public const string ATTRIBUTE_VALUE = 'value';
/**
* The table associated with the model.
* Get the attributes that should be cast.
*
* @var string
* @return array<string, string>
*/
protected $table = LikeAggregate::TABLE;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
protected function casts(): array
{
return [
LikeAggregate::ATTRIBUTE_LIKEABLE_TYPE => 'string',
LikeAggregate::ATTRIBUTE_LIKEABLE_ID => 'int',
LikeAggregate::ATTRIBUTE_VALUE => 'int',
];
}
public function likeable(): MorphTo
{
+13
View File
@@ -29,6 +29,19 @@ class Permission extends BasePermission implements Nameable
final public const string RELATION_ROLES = 'roles';
final public const string RELATION_USERS = 'users';
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Permission::ATTRIBUTE_GUARD_NAME => 'string',
Permission::ATTRIBUTE_NAME => 'string',
];
}
public function getName(): string
{
return $this->name;
+12
View File
@@ -20,6 +20,18 @@ class Prohibition extends BaseProhibition implements Nameable
final public const string RELATION_SANCTIONS = 'sanctions';
final public const string RELATION_USERS = 'users';
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Prohibition::ATTRIBUTE_NAME => 'string',
];
}
public function getName(): string
{
return $this->name;
+3
View File
@@ -47,7 +47,10 @@ class Role extends BaseRole implements Nameable
protected function casts(): array
{
return [
Role::ATTRIBUTE_COLOR => 'string',
Role::ATTRIBUTE_DEFAULT => 'boolean',
Role::ATTRIBUTE_GUARD_NAME => 'string',
Role::ATTRIBUTE_NAME => 'string',
Role::ATTRIBUTE_PRIORITY => 'int',
];
}
+12
View File
@@ -20,6 +20,18 @@ class Sanction extends BaseSanction implements Nameable
final public const string RELATION_PROHIBITIONS = 'prohibitions';
final public const string RELATION_USERS = 'users';
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Sanction::ATTRIBUTE_NAME => 'string',
];
}
public function getName(): string
{
return $this->name;
+12 -26
View File
@@ -28,6 +28,8 @@ use Filament\Models\Contracts\HasAvatar;
use Filament\Notifications\DatabaseNotification as FilamentNotification;
use Filament\Panel;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -64,6 +66,13 @@ use Spatie\Permission\Traits\HasRoles;
*
* @method static UserFactory factory(...$parameters)
*/
#[Hidden([
User::ATTRIBUTE_PASSWORD,
User::ATTRIBUTE_REMEMBER_TOKEN,
User::ATTRIBUTE_TWO_FACTOR_RECOVERY_CODES,
User::ATTRIBUTE_TWO_FACTOR_SECRET,
])]
#[Table(User::TABLE, dateFormat: 'Y-m-d\TH:i:s.u')]
class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtitle, MustVerifyEmail, Nameable, SoftDeletable
{
use HasApiTokens;
@@ -99,13 +108,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
final public const string RELATION_ROLES_PERMISSIONS = 'roles.permissions';
final public const string RELATION_WATCH_HISTORY = 'watchHistory';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = User::TABLE;
/**
* The event map for the model.
*
@@ -132,25 +134,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
User::ATTRIBUTE_EMAIL_VERIFIED_AT,
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
User::ATTRIBUTE_PASSWORD,
User::ATTRIBUTE_REMEMBER_TOKEN,
User::ATTRIBUTE_TWO_FACTOR_RECOVERY_CODES,
User::ATTRIBUTE_TWO_FACTOR_SECRET,
];
/**
* The storage format of the model's date columns.
*
* @var string
*/
protected $dateFormat = 'Y-m-d\TH:i:s.u';
/**
* Get the attributes that should be cast.
*
@@ -159,8 +142,11 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
protected function casts(): array
{
return [
User::ATTRIBUTE_EMAIL => 'string',
User::ATTRIBUTE_EMAIL_VERIFIED_AT => 'datetime',
User::ATTRIBUTE_NAME => 'string',
User::ATTRIBUTE_PASSWORD => 'hashed',
User::ATTRIBUTE_REMEMBER_TOKEN => 'string',
];
}
+15 -28
View File
@@ -11,6 +11,7 @@ use App\Models\Wiki\Anime;
use App\Observers\Discord\DiscordThreadObserver;
use Database\Factories\Discord\DiscordThreadFactory;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -23,6 +24,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static DiscordThreadFactory factory(...$parameters)
*/
#[ObservedBy(DiscordThreadObserver::class)]
#[Table(DiscordThread::TABLE, DiscordThread::ATTRIBUTE_ID, 'string', false)]
class DiscordThread extends BaseModel
{
use HasFactory;
@@ -35,34 +37,6 @@ class DiscordThread extends BaseModel
final public const string RELATION_ANIME = 'anime';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = DiscordThread::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = DiscordThread::ATTRIBUTE_ID;
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* The data type of the primary key ID.
*
* @var string
*/
protected $keyType = 'string';
/**
* The event map for the model.
*
@@ -86,6 +60,19 @@ class DiscordThread extends BaseModel
DiscordThread::ATTRIBUTE_NAME,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
DiscordThread::ATTRIBUTE_ANIME => 'int',
DiscordThread::ATTRIBUTE_NAME => 'string',
];
}
public function getName(): string
{
return $this->name;
+16 -19
View File
@@ -17,7 +17,9 @@ use App\Models\BaseModel;
use App\Pivots\Document\PageRole;
use App\Scopes\ReadablePagesScope;
use Database\Factories\Document\PageFactory;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Attributes\ScopedBy;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -40,7 +42,9 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static PageFactory factory(...$parameters)
*/
#[Hidden([Page::ATTRIBUTE_BODY])]
#[ScopedBy(ReadablePagesScope::class)]
#[Table(Page::TABLE, Page::ATTRIBUTE_ID)]
class Page extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -63,20 +67,6 @@ class Page extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_ROLES = 'roles';
final public const string RELATION_VIEWER_ROLES = 'viewerRoles';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Page::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Page::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -105,13 +95,20 @@ class Page extends BaseModel implements Auditable, SoftDeletable
];
/**
* The attributes that should be hidden for serialization.
* Get the attributes that should be cast.
*
* @var list<string>
* @return array<string, string>
*/
protected $hidden = [
Page::ATTRIBUTE_BODY,
];
protected function casts(): array
{
return [
Page::ATTRIBUTE_BODY => 'string',
Page::ATTRIBUTE_NAME => 'string',
Page::ATTRIBUTE_NEXT => 'int',
Page::ATTRIBUTE_PREVIOUS => 'int',
Page::ATTRIBUTE_SLUG => 'string',
];
}
/**
* Get the route key for the model.
+11 -20
View File
@@ -4,11 +4,12 @@ declare(strict_types=1);
namespace App\Models\List\External;
use App\Enums\Models\List\ExternalEntryWatchStatus;
use App\Enums\Models\List\ExternalEntryStatus;
use App\Models\BaseModel;
use App\Models\List\ExternalProfile;
use App\Models\Wiki\Anime;
use Database\Factories\List\External\ExternalEntryFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -20,10 +21,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property ExternalProfile $externalprofile
* @property bool $is_favorite
* @property float|null $score
* @property ExternalEntryWatchStatus $watch_status
* @property ExternalEntryStatus $status
*
* @method static ExternalEntryFactory factory(...$parameters)
*/
#[Table(ExternalEntry::TABLE, ExternalEntry::ATTRIBUTE_ID)]
class ExternalEntry extends BaseModel
{
use HasFactory;
@@ -35,26 +37,12 @@ class ExternalEntry extends BaseModel
final public const string ATTRIBUTE_PROFILE = 'profile_id';
final public const string ATTRIBUTE_IS_FAVORITE = 'is_favorite';
final public const string ATTRIBUTE_SCORE = 'score';
final public const string ATTRIBUTE_WATCH_STATUS = 'watch_status';
final public const string ATTRIBUTE_STATUS = 'status';
final public const string RELATION_ANIME = 'anime';
final public const string RELATION_PROFILE = 'externalprofile';
final public const string RELATION_USER = 'externalprofile.user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ExternalEntry::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = ExternalEntry::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -65,7 +53,7 @@ class ExternalEntry extends BaseModel
ExternalEntry::ATTRIBUTE_PROFILE,
ExternalEntry::ATTRIBUTE_IS_FAVORITE,
ExternalEntry::ATTRIBUTE_SCORE,
ExternalEntry::ATTRIBUTE_WATCH_STATUS,
ExternalEntry::ATTRIBUTE_STATUS,
];
/**
@@ -76,8 +64,11 @@ class ExternalEntry extends BaseModel
protected function casts(): array
{
return [
ExternalEntry::ATTRIBUTE_ANIME => 'int',
ExternalEntry::ATTRIBUTE_PROFILE => 'int',
ExternalEntry::ATTRIBUTE_IS_FAVORITE => 'bool',
ExternalEntry::ATTRIBUTE_WATCH_STATUS => ExternalEntryWatchStatus::class,
ExternalEntry::ATTRIBUTE_SCORE => 'float',
ExternalEntry::ATTRIBUTE_STATUS => ExternalEntryStatus::class,
];
}
@@ -101,7 +92,7 @@ class ExternalEntry extends BaseModel
return [
ExternalEntry::ATTRIBUTE_IS_FAVORITE,
ExternalEntry::ATTRIBUTE_SCORE,
ExternalEntry::ATTRIBUTE_WATCH_STATUS,
ExternalEntry::ATTRIBUTE_STATUS,
];
}
+17 -20
View File
@@ -8,6 +8,8 @@ use App\Models\Auth\User;
use App\Models\BaseModel;
use App\Models\List\ExternalProfile;
use Database\Factories\List\External\ExternalTokenFactory;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Znck\Eloquent\Relations\BelongsToThrough;
@@ -24,6 +26,11 @@ use Znck\Eloquent\Traits\BelongsToThrough as TraitsBelongsToThrough;
*
* @method static ExternalTokenFactory factory(...$parameters)
*/
#[Hidden([
ExternalToken::ATTRIBUTE_ACCESS_TOKEN,
ExternalToken::ATTRIBUTE_REFRESH_TOKEN,
])]
#[Table(ExternalToken::TABLE, ExternalToken::ATTRIBUTE_ID)]
class ExternalToken extends BaseModel
{
use HasFactory;
@@ -40,20 +47,6 @@ class ExternalToken extends BaseModel
final public const string RELATION_USER = 'externalprofile.user';
final public const string RELATION_USER_SHALLOW = 'user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ExternalToken::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = ExternalToken::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -66,14 +59,18 @@ class ExternalToken extends BaseModel
];
/**
* The attributes that should be hidden for serialization.
* Get the attributes that should be cast.
*
* @var list<string>
* @return array<string, string>
*/
protected $hidden = [
ExternalToken::ATTRIBUTE_ACCESS_TOKEN,
ExternalToken::ATTRIBUTE_REFRESH_TOKEN,
];
protected function casts(): array
{
return [
ExternalToken::ATTRIBUTE_ACCESS_TOKEN => 'string',
ExternalToken::ATTRIBUTE_PROFILE => 'int',
ExternalToken::ATTRIBUTE_REFRESH_TOKEN => 'string',
];
}
public function getName(): string
{
+6 -14
View File
@@ -17,6 +17,7 @@ use App\Models\List\External\ExternalEntry;
use App\Models\List\External\ExternalToken;
use Database\Factories\List\ExternalProfileFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Prunable;
@@ -44,6 +45,7 @@ use Illuminate\Support\Uri;
*
* @method static ExternalProfileFactory factory(...$parameters)
*/
#[Table(ExternalProfile::TABLE, ExternalProfile::ATTRIBUTE_ID)]
class ExternalProfile extends BaseModel
{
use HasFactory;
@@ -65,20 +67,6 @@ class ExternalProfile extends BaseModel
final public const string RELATION_EXTERNAL_TOKEN = 'externaltoken';
final public const string RELATION_USER = 'user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ExternalProfile::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = ExternalProfile::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -114,8 +102,12 @@ class ExternalProfile extends BaseModel
protected function casts(): array
{
return [
ExternalProfile::ATTRIBUTE_EXTERNAL_USER_ID => 'int',
ExternalProfile::ATTRIBUTE_NAME => 'string',
ExternalProfile::ATTRIBUTE_SITE => ExternalProfileSite::class,
ExternalProfile::ATTRIBUTE_SYNCED_AT => 'datetime',
ExternalProfile::ATTRIBUTE_VISIBILITY => ExternalProfileVisibility::class,
ExternalProfile::ATTRIBUTE_USER => 'int',
];
}
+8 -14
View File
@@ -21,6 +21,7 @@ use App\Models\Wiki\Image;
use App\Pivots\Morph\Imageable;
use Database\Factories\List\PlaylistFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -43,6 +44,7 @@ use Illuminate\Support\Collection;
*
* @method static PlaylistFactory factory(...$parameters)
*/
#[Table(Playlist::TABLE, Playlist::ATTRIBUTE_ID)]
class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasImages, Likeable
{
use AggregatesLike;
@@ -66,20 +68,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
final public const string RELATION_TRACKS = 'tracks';
final public const string RELATION_USER = 'user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Playlist::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Playlist::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -123,6 +111,12 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
protected function casts(): array
{
return [
Playlist::ATTRIBUTE_DESCRIPTION => 'string',
Playlist::ATTRIBUTE_FIRST => 'int',
Playlist::ATTRIBUTE_HASHID => 'string',
Playlist::ATTRIBUTE_LAST => 'int',
Playlist::ATTRIBUTE_NAME => 'string',
Playlist::ATTRIBUTE_USER => 'int',
Playlist::ATTRIBUTE_VISIBILITY => PlaylistVisibility::class,
];
}
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Models\List\Playlist;
use Illuminate\Database\Eloquent\Attributes\Table;
#[Table(PlaylistTrack::TABLE, PlaylistTrack::ATTRIBUTE_ID)]
class BackwardPlaylistTrack extends PlaylistTrack
{
/**
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Models\List\Playlist;
use Illuminate\Database\Eloquent\Attributes\Table;
#[Table(PlaylistTrack::TABLE, PlaylistTrack::ATTRIBUTE_ID)]
class ForwardPlaylistTrack extends PlaylistTrack
{
/**
+5 -14
View File
@@ -15,6 +15,7 @@ use App\Models\List\Playlist;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Video;
use Database\Factories\List\Playlist\PlaylistTrackFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -39,6 +40,7 @@ use Staudenmeir\LaravelAdjacencyList\Eloquent\HasRecursiveRelationships;
*
* @method static PlaylistTrackFactory factory(...$parameters)
*/
#[Table(PlaylistTrack::TABLE, PlaylistTrack::ATTRIBUTE_ID)]
class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema, Sortable
{
use HasFactory;
@@ -65,20 +67,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
final public const string RELATION_THEME_GROUP = 'animethemeentry.animetheme.group';
final public const string RELATION_VIDEO = 'video';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = PlaylistTrack::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = PlaylistTrack::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -112,7 +100,10 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
protected function casts(): array
{
return [
PlaylistTrack::ATTRIBUTE_ENTRY => 'int',
PlaylistTrack::ATTRIBUTE_PLAYLIST => 'int',
PlaylistTrack::ATTRIBUTE_POSITION => 'int',
PlaylistTrack::ATTRIBUTE_VIDEO => 'int',
];
}
+16 -14
View File
@@ -7,6 +7,7 @@ namespace App\Models\User;
use App\Models\Auth\User;
use App\Models\BaseModel;
use Database\Factories\User\LikeFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -21,6 +22,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
*
* @method static LikeFactory factory(...$parameters)
*/
#[Table(Like::TABLE, Like::ATTRIBUTE_ID)]
class Like extends BaseModel
{
use HasFactory;
@@ -37,20 +39,6 @@ class Like extends BaseModel
final public const string RELATION_USER = 'user';
final public const string RELATION_LIKEABLE = 'likeable';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Like::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Like::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -62,6 +50,20 @@ class Like extends BaseModel
Like::ATTRIBUTE_LIKEABLE_ID,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Like::ATTRIBUTE_LIKEABLE_TYPE => 'string',
Like::ATTRIBUTE_LIKEABLE_ID => 'int',
Like::ATTRIBUTE_USER => 'int',
];
}
public function getName(): string
{
return strval($this->getKey());
+8 -14
View File
@@ -10,6 +10,7 @@ use App\Models\BaseModel;
use App\Models\User\Submission\SubmissionStage;
use Database\Factories\User\SubmissionFactory;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -34,6 +35,7 @@ use Illuminate\Support\Collection;
* @method static Builder pending()
* @method static SubmissionFactory factory(...$parameters)
*/
#[Table(Submission::TABLE, Submission::ATTRIBUTE_ID)]
class Submission extends BaseModel
{
use HasFactory;
@@ -56,20 +58,6 @@ class Submission extends BaseModel
final public const string RELATION_STAGES = 'stages';
final public const string RELATION_USER = 'user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Submission::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Submission::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -95,9 +83,15 @@ class Submission extends BaseModel
protected function casts(): array
{
return [
Submission::ATTRIBUTE_ACTIONABLE_TYPE => 'string',
Submission::ATTRIBUTE_ACTIONABLE_ID => 'int',
Submission::ATTRIBUTE_FINISHED_AT => 'datetime',
Submission::ATTRIBUTE_LOCKED => 'bool',
Submission::ATTRIBUTE_MODERATOR => 'int',
Submission::ATTRIBUTE_MODERATOR_NOTES => 'string',
Submission::ATTRIBUTE_STATUS => SubmissionStatus::class,
Submission::ATTRIBUTE_TYPE => 'string',
Submission::ATTRIBUTE_USER => 'int',
];
}
+19 -27
View File
@@ -8,6 +8,7 @@ use App\Models\Auth\User;
use App\Models\BaseModel;
use App\Models\User\Submission;
use Database\Factories\User\Submission\SubmissionStageFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -24,6 +25,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*
* @method static SubmissionStageFactory factory(...$parameters)
*/
#[Table(SubmissionStage::TABLE, SubmissionStage::ATTRIBUTE_ID)]
class SubmissionStage extends BaseModel
{
use HasFactory;
@@ -42,20 +44,6 @@ class SubmissionStage extends BaseModel
final public const string RELATION_MODERATOR = 'moderator';
final public const string RELATION_SUBMISSION = 'submission';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = SubmissionStage::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = SubmissionStage::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -70,6 +58,23 @@ class SubmissionStage extends BaseModel
SubmissionStage::ATTRIBUTE_SUBMISSION,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
SubmissionStage::ATTRIBUTE_FIELDS => 'array',
SubmissionStage::ATTRIBUTE_MODERATOR => 'int',
SubmissionStage::ATTRIBUTE_MODERATOR_NOTES => 'string',
SubmissionStage::ATTRIBUTE_NOTES => 'string',
SubmissionStage::ATTRIBUTE_STAGE => 'int',
SubmissionStage::ATTRIBUTE_SUBMISSION => 'int',
];
}
public function getName(): string
{
return strval($this->getKey());
@@ -80,19 +85,6 @@ class SubmissionStage extends BaseModel
return strval($this->getKey());
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
SubmissionStage::ATTRIBUTE_FIELDS => 'array',
SubmissionStage::ATTRIBUTE_STAGE => 'int',
];
}
/**
* @return BelongsTo<Submission, $this>
*/
@@ -7,7 +7,9 @@ namespace App\Models\User\Submission;
use App\Models\Auth\User;
use App\Models\BaseModel;
use App\Observers\User\Submission\SubmissionVirtualObserver;
use Illuminate\Database\Eloquent\Attributes\Appends;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -22,7 +24,9 @@ use Illuminate\Database\Eloquent\Relations\Relation;
* @property int $user_id
* @property User $user
*/
#[Appends(['model'])]
#[ObservedBy(SubmissionVirtualObserver::class)]
#[Table(SubmissionVirtual::TABLE, SubmissionVirtual::ATTRIBUTE_ID)]
class SubmissionVirtual extends BaseModel
{
final public const string TABLE = 'submission_virtuals';
@@ -36,20 +40,6 @@ class SubmissionVirtual extends BaseModel
final public const string RELATION_USER = 'user';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = SubmissionVirtual::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = SubmissionVirtual::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -62,9 +52,20 @@ class SubmissionVirtual extends BaseModel
SubmissionVirtual::ATTRIBUTE_USER,
];
protected $appends = [
'model',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
SubmissionVirtual::ATTRIBUTE_EXISTS => 'boolean',
SubmissionVirtual::ATTRIBUTE_FIELDS => 'array',
SubmissionVirtual::ATTRIBUTE_MODEL_TYPE => 'string',
SubmissionVirtual::ATTRIBUTE_USER => 'int',
];
}
public function getName(): string
{
@@ -81,19 +82,6 @@ class SubmissionVirtual extends BaseModel
return Attribute::make(fn () => Relation::getMorphedModel($this->model_type) ?? $this->model_type);
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
SubmissionVirtual::ATTRIBUTE_EXISTS => 'boolean',
SubmissionVirtual::ATTRIBUTE_FIELDS => 'array',
];
}
/**
* @return BelongsTo<User, $this>
*/
+16 -14
View File
@@ -9,6 +9,7 @@ use App\Models\BaseModel;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Video;
use Database\Factories\User\WatchHistoryFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -22,6 +23,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*
* @method static WatchHistoryFactory factory(...$parameters)
*/
#[Table(WatchHistory::TABLE, WatchHistory::ATTRIBUTE_ID)]
class WatchHistory extends BaseModel
{
use HasFactory;
@@ -37,20 +39,6 @@ class WatchHistory extends BaseModel
final public const string RELATION_USER = 'user';
final public const string RELATION_VIDEO = 'video';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = WatchHistory::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = WatchHistory::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -62,6 +50,20 @@ class WatchHistory extends BaseModel
WatchHistory::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
WatchHistory::ATTRIBUTE_ENTRY => 'int',
WatchHistory::ATTRIBUTE_USER => 'int',
WatchHistory::ATTRIBUTE_VIDEO => 'int',
];
}
public function getName(): string
{
return strval($this->getKey());
+7 -16
View File
@@ -31,6 +31,7 @@ use App\Pivots\Wiki\AnimeStudio;
use Database\Factories\Wiki\AnimeFactory;
use Deprecated;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -61,6 +62,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static AnimeFactory factory(...$parameters)
*/
#[Table(Anime::TABLE, Anime::ATTRIBUTE_ID)]
class Anime extends BaseModel implements Auditable, HasImages, HasResources, HasSynonyms, SoftDeletable
{
use HasAudits;
@@ -96,20 +98,6 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
final public const string RELATION_THEMES = 'animethemes';
final public const string RELATION_VIDEOS = 'animethemes.animethemeentries.videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Anime::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Anime::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -147,9 +135,12 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
protected function casts(): array
{
return [
Anime::ATTRIBUTE_SEASON => AnimeSeason::class,
Anime::ATTRIBUTE_YEAR => 'int',
Anime::ATTRIBUTE_NAME => 'string',
Anime::ATTRIBUTE_MEDIA_FORMAT => AnimeMediaFormat::class,
Anime::ATTRIBUTE_SEASON => AnimeSeason::class,
Anime::ATTRIBUTE_SLUG => 'string',
Anime::ATTRIBUTE_SYNOPSIS => 'string',
Anime::ATTRIBUTE_YEAR => 'int',
];
}
+4 -14
View File
@@ -11,6 +11,7 @@ use App\Enums\Models\Wiki\AnimeSynonymType;
use App\Models\BaseModel;
use App\Models\Wiki\Anime;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use OwenIt\Auditing\Auditable as HasAudits;
@@ -25,6 +26,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @deprecated Use Synonym instead.
*/
#[Table(AnimeSynonym::TABLE, AnimeSynonym::ATTRIBUTE_ID)]
class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -44,20 +46,6 @@ class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_SERIES = 'anime.series';
final public const string RELATION_VIDEOS = 'anime.animethemes.animethemeentries.videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = AnimeSynonym::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = AnimeSynonym::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -77,6 +65,8 @@ class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable
protected function casts(): array
{
return [
AnimeSynonym::ATTRIBUTE_ANIME => 'int',
AnimeSynonym::ATTRIBUTE_TEXT => 'string',
AnimeSynonym::ATTRIBUTE_TYPE => AnimeSynonymType::class,
];
}
+7 -27
View File
@@ -15,7 +15,6 @@ use App\Events\Wiki\Anime\Theme\ThemeDeleting;
use App\Events\Wiki\Anime\Theme\ThemeRestored;
use App\Events\Wiki\Anime\Theme\ThemeUpdated;
use App\Http\Api\Schema\Wiki\Anime\ThemeSchema;
use App\Http\Middleware\Api\SetServingJsonApi;
use App\Models\BaseModel;
use App\Models\Wiki\Anime;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
@@ -26,6 +25,8 @@ use App\Scopes\WithoutInsertSongScope;
use Database\Factories\Wiki\Anime\AnimeThemeFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Attributes\ScopedBy;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -52,6 +53,8 @@ use OwenIt\Auditing\Contracts\Auditable;
* @method static AnimeThemeFactory factory(...$parameters)
*/
#[ObservedBy(AnimeThemeObserver::class)]
#[ScopedBy(WithoutInsertSongScope::class)]
#[Table(AnimeTheme::TABLE, AnimeTheme::ATTRIBUTE_ID)]
class AnimeTheme extends BaseModel implements Auditable, InteractsWithSchema, SoftDeletable
{
use HasAudits;
@@ -82,32 +85,6 @@ class AnimeTheme extends BaseModel implements Auditable, InteractsWithSchema, So
final public const string RELATION_SYNONYMS = 'anime.synonyms';
final public const string RELATION_VIDEOS = 'animethemeentries.videos';
/**
* The "boot" method of the model.
*/
protected static function boot(): void
{
parent::boot();
if (SetServingJsonApi::$isServing) {
static::addGlobalScope(new WithoutInsertSongScope);
}
}
/**
* The table associated with the model.
*
* @var string
*/
protected $table = AnimeTheme::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = AnimeTheme::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -145,7 +122,10 @@ class AnimeTheme extends BaseModel implements Auditable, InteractsWithSchema, So
protected function casts(): array
{
return [
AnimeTheme::ATTRIBUTE_ANIME => 'int',
AnimeTheme::ATTRIBUTE_GROUP => 'int',
AnimeTheme::ATTRIBUTE_SEQUENCE => 'int',
AnimeTheme::ATTRIBUTE_SLUG => 'string',
AnimeTheme::ATTRIBUTE_SONG => 'int',
AnimeTheme::ATTRIBUTE_TYPE => ThemeType::class,
];
@@ -32,6 +32,7 @@ use App\Pivots\Morph\Resourceable;
use App\Pivots\Wiki\AnimeThemeEntryVideo;
use Database\Factories\Wiki\Anime\Theme\AnimeThemeEntryFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -61,6 +62,7 @@ use Znck\Eloquent\Traits\BelongsToThrough as ZnckBelongsToThrough;
*
* @method static AnimeThemeEntryFactory factory(...$parameters)
*/
#[Table(AnimeThemeEntry::TABLE, AnimeThemeEntry::ATTRIBUTE_ID)]
class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes, HasResources, InteractsWithSchema, Likeable, SoftDeletable
{
use AggregatesLike;
@@ -93,20 +95,6 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
final public const string RELATION_TRACKS = 'tracks';
final public const string RELATION_VIDEOS = 'videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = AnimeThemeEntry::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = AnimeThemeEntry::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -144,8 +132,11 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
protected function casts(): array
{
return [
AnimeThemeEntry::ATTRIBUTE_EPISODES => 'string',
AnimeThemeEntry::ATTRIBUTE_NOTES => 'string',
AnimeThemeEntry::ATTRIBUTE_NSFW => 'boolean',
AnimeThemeEntry::ATTRIBUTE_SPOILER => 'boolean',
AnimeThemeEntry::ATTRIBUTE_THEME => 'int',
AnimeThemeEntry::ATTRIBUTE_VERSION => 'int',
];
}
+16 -14
View File
@@ -27,6 +27,7 @@ use App\Pivots\Wiki\ArtistSong;
use Database\Factories\Wiki\ArtistFactory;
use Deprecated;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -56,6 +57,7 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
*
* @method static ArtistFactory factory(...$parameters)
*/
#[Table(Artist::TABLE, Artist::ATTRIBUTE_ID)]
class Artist extends BaseModel implements Auditable, HasImages, HasResources, HasSynonyms, SoftDeletable
{
use HasAudits;
@@ -90,20 +92,6 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
final public const string RELATION_THEME_GROUPS = 'songs.animethemes.group';
final public const string RELATION_UNIQUE_GROUPSHIPS_PERFORMANCES = 'uniquegroupshipperformances';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Artist::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Artist::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -130,6 +118,20 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
Artist::ATTRIBUTE_INFORMATION,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Artist::ATTRIBUTE_INFORMATION => 'string',
Artist::ATTRIBUTE_NAME => 'string',
Artist::ATTRIBUTE_SLUG => 'string',
];
}
/**
* Modify the query used to retrieve models when making all of the models searchable.
*/
+8 -23
View File
@@ -15,6 +15,8 @@ use App\Events\Wiki\Audio\AudioRestored;
use App\Events\Wiki\Audio\AudioUpdated;
use App\Models\BaseModel;
use Database\Factories\Wiki\AudioFactory;
use Illuminate\Database\Eloquent\Attributes\Appends;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -34,6 +36,8 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static AudioFactory factory(...$parameters)
*/
#[Appends([Audio::ATTRIBUTE_LINK])]
#[Table(Audio::TABLE, Audio::ATTRIBUTE_ID)]
class Audio extends BaseModel implements Auditable, SoftDeletable, Streamable
{
use HasAudits;
@@ -53,20 +57,6 @@ class Audio extends BaseModel implements Auditable, SoftDeletable, Streamable
final public const string RELATION_VIDEOS = 'videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Audio::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Audio::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -95,15 +85,6 @@ class Audio extends BaseModel implements Auditable, SoftDeletable, Streamable
Audio::ATTRIBUTE_SIZE,
];
/**
* The accessors to append to the model's array form.
*
* @var list<string>
*/
protected $appends = [
Audio::ATTRIBUTE_LINK,
];
/**
* Get the attributes that should be cast.
*
@@ -112,6 +93,10 @@ class Audio extends BaseModel implements Auditable, SoftDeletable, Streamable
protected function casts(): array
{
return [
Audio::ATTRIBUTE_BASENAME => 'string',
Audio::ATTRIBUTE_FILENAME => 'string',
Audio::ATTRIBUTE_MIMETYPE => 'string',
Audio::ATTRIBUTE_PATH => 'string',
Audio::ATTRIBUTE_SIZE => 'int',
];
}
+2 -14
View File
@@ -16,6 +16,7 @@ use App\Models\BaseModel;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Pivots\Morph\Resourceable;
use Database\Factories\Wiki\ExternalResourceFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Casts\AsUri;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
@@ -36,6 +37,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static ExternalResourceFactory factory(...$parameters)
*/
#[Table(ExternalResource::TABLE, ExternalResource::ATTRIBUTE_ID)]
class ExternalResource extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -56,20 +58,6 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_SONGS = 'songs';
final public const string RELATION_STUDIOS = 'studios';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = ExternalResource::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = ExternalResource::ATTRIBUTE_ID;
/**
* The event map for the model.
*
+15 -14
View File
@@ -15,6 +15,7 @@ use App\Events\Wiki\Group\GroupUpdated;
use App\Models\BaseModel;
use App\Models\Wiki\Anime\AnimeTheme;
use Database\Factories\Wiki\GroupFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;
@@ -29,6 +30,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static GroupFactory factory(...$parameters)
*/
#[Table(Group::TABLE, Group::ATTRIBUTE_ID)]
class Group extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -46,20 +48,6 @@ class Group extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_THEMES = 'animethemes';
final public const string RELATION_VIDEOS = 'animethemes.animethemeentries.videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Group::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Group::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -85,6 +73,19 @@ class Group extends BaseModel implements Auditable, SoftDeletable
Group::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Group::ATTRIBUTE_NAME => 'string',
Group::ATTRIBUTE_SLUG => 'string',
];
}
public function getName(): string
{
return $this->name;
+5 -23
View File
@@ -17,6 +17,8 @@ use App\Models\BaseModel;
use App\Models\List\Playlist;
use App\Pivots\Morph\Imageable;
use Database\Factories\Wiki\ImageFactory;
use Illuminate\Database\Eloquent\Attributes\Appends;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
@@ -40,6 +42,8 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static ImageFactory factory(...$parameters)
*/
#[Appends([Image::ATTRIBUTE_LINK])]
#[Table(Image::TABLE, Image::ATTRIBUTE_ID)]
class Image extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -59,20 +63,6 @@ class Image extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_PLAYLISTS = 'playlists';
final public const string RELATION_STUDIOS = 'studios';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Image::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Image::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -98,15 +88,6 @@ class Image extends BaseModel implements Auditable, SoftDeletable
Image::ATTRIBUTE_PATH,
];
/**
* The accessors to append to the model's array form.
*
* @var list<string>
*/
protected $appends = [
Image::ATTRIBUTE_LINK,
];
/**
* Get the attributes that should be cast.
*
@@ -116,6 +97,7 @@ class Image extends BaseModel implements Auditable, SoftDeletable
{
return [
Image::ATTRIBUTE_FACET => ImageFacet::class,
Image::ATTRIBUTE_PATH => 'string',
];
}
+15 -14
View File
@@ -16,6 +16,7 @@ use App\Models\BaseModel;
use App\Pivots\Wiki\AnimeSeries;
use Database\Factories\Wiki\SeriesFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -31,6 +32,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static SeriesFactory factory(...$parameters)
*/
#[Table(Series::TABLE, Series::ATTRIBUTE_ID)]
class Series extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -48,20 +50,6 @@ class Series extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_ANIME = 'anime';
final public const string RELATION_ANIME_SYNONYMS = 'anime.synonyms';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Series::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Series::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -86,6 +74,19 @@ class Series extends BaseModel implements Auditable, SoftDeletable
Series::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Series::ATTRIBUTE_NAME => 'string',
Series::ATTRIBUTE_SLUG => 'string',
];
}
/**
* Modify the query used to retrieve models when making all of the models searchable.
*/
+15 -14
View File
@@ -22,6 +22,7 @@ use App\Pivots\Wiki\ArtistSong;
use Database\Factories\Wiki\SongFactory;
use Deprecated;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -41,6 +42,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static SongFactory factory(...$parameters)
*/
#[Table(Song::TABLE, Song::ATTRIBUTE_ID)]
class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
{
use HasAudits;
@@ -64,20 +66,6 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
final public const string RELATION_THEME_GROUPS = 'animethemes.group';
final public const string RELATION_VIDEOS = 'animethemes.animethemeentries.videos';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Song::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Song::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -103,6 +91,19 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
Song::ATTRIBUTE_TITLE_NATIVE,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Song::ATTRIBUTE_TITLE => 'string',
Song::ATTRIBUTE_TITLE_NATIVE => 'string',
];
}
public function getName(): string
{
if (blank($this->title)) {
+17 -14
View File
@@ -15,6 +15,7 @@ use App\Events\Wiki\Song\Membership\MembershipUpdated;
use App\Models\BaseModel;
use App\Models\Wiki\Artist;
use Database\Factories\Wiki\Song\MembershipFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
@@ -34,6 +35,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static MembershipFactory factory(...$parameters)
*/
#[Table(Membership::TABLE, Membership::ATTRIBUTE_ID)]
class Membership extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -53,20 +55,6 @@ class Membership extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_MEMBER = 'member';
final public const string RELATION_PERFORMANCES = 'performances';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Membership::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Membership::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -94,6 +82,21 @@ class Membership extends BaseModel implements Auditable, SoftDeletable
Membership::ATTRIBUTE_MEMBER,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Membership::ATTRIBUTE_ALIAS => 'string',
Membership::ATTRIBUTE_ARTIST => 'int',
Membership::ATTRIBUTE_AS => 'string',
Membership::ATTRIBUTE_MEMBER => 'int',
];
}
public function getName(): string
{
return strval($this->getKey());
+19 -14
View File
@@ -16,6 +16,7 @@ use App\Models\BaseModel;
use App\Models\Wiki\Artist;
use App\Models\Wiki\Song;
use Database\Factories\Wiki\Song\PerformanceFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -38,6 +39,7 @@ use Spatie\EloquentSortable\SortableTrait;
*
* @method static PerformanceFactory factory(...$parameters)
*/
#[Table(Performance::TABLE, Performance::ATTRIBUTE_ID)]
class Performance extends BaseModel implements Auditable, SoftDeletable, Sortable
{
use HasAudits;
@@ -63,20 +65,6 @@ class Performance extends BaseModel implements Auditable, SoftDeletable, Sortabl
final public const string RELATION_MEMBER = 'artist.member';
final public const string RELATION_SONG = 'song';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Performance::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Performance::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -111,6 +99,23 @@ class Performance extends BaseModel implements Auditable, SoftDeletable, Sortabl
'sort_when_creating' => false,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Performance::ATTRIBUTE_ALIAS => 'string',
Performance::ATTRIBUTE_ARTIST_TYPE => 'string',
Performance::ATTRIBUTE_ARTIST_ID => 'int',
Performance::ATTRIBUTE_AS => 'string',
Performance::ATTRIBUTE_RELEVANCE => 'int',
Performance::ATTRIBUTE_SONG => 'int',
];
}
public function getName(): string
{
return strval($this->getKey());
+15 -14
View File
@@ -20,6 +20,7 @@ use App\Pivots\Morph\Resourceable;
use App\Pivots\Wiki\AnimeStudio;
use Database\Factories\Wiki\StudioFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
@@ -36,6 +37,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static StudioFactory factory(...$parameters)
*/
#[Table(Studio::TABLE, Studio::ATTRIBUTE_ID)]
class Studio extends BaseModel implements Auditable, HasImages, HasResources, SoftDeletable
{
use HasAudits;
@@ -54,20 +56,6 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
final public const string RELATION_IMAGES = 'images';
final public const string RELATION_RESOURCES = 'resources';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Studio::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Studio::ATTRIBUTE_ID;
/**
* The event map for the model.
*
@@ -92,6 +80,19 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
Studio::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Studio::ATTRIBUTE_NAME => 'string',
Studio::ATTRIBUTE_SLUG => 'string',
];
}
/**
* Get the route key for the model.
*
+5 -14
View File
@@ -17,6 +17,7 @@ use App\Events\Wiki\Synonym\SynonymUpdated;
use App\Models\BaseModel;
use Database\Factories\Wiki\SynonymFactory;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -33,6 +34,7 @@ use OwenIt\Auditing\Contracts\Auditable;
*
* @method static SynonymFactory factory(...$parameters)
*/
#[Table(Synonym::TABLE, Synonym::ATTRIBUTE_ID)]
class Synonym extends BaseModel implements Auditable, SoftDeletable
{
use HasAudits;
@@ -51,20 +53,6 @@ class Synonym extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_SYNONYMABLE = 'synonymable';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = Synonym::TABLE;
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = Synonym::ATTRIBUTE_ID;
/**
* The attributes that are mass assignable.
*
@@ -99,6 +87,9 @@ class Synonym extends BaseModel implements Auditable, SoftDeletable
protected function casts(): array
{
return [
Synonym::ATTRIBUTE_SYNONYMABLE_TYPE => 'string',
Synonym::ATTRIBUTE_SYNONYMABLE_ID => 'int',
Synonym::ATTRIBUTE_TEXT => 'string',
Synonym::ATTRIBUTE_TYPE => SynonymType::class,
];
}

Some files were not shown because too many files have changed in this diff Show More