diff --git a/app/Filament/Components/Fields/Slug.php b/app/Filament/Components/Fields/Slug.php index dda1b3c19..e8fc9e715 100644 --- a/app/Filament/Components/Fields/Slug.php +++ b/app/Filament/Components/Fields/Slug.php @@ -5,8 +5,6 @@ namespace App\Filament\Components\Fields; use Filament\Forms\Components\TextInput; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Validation\Rule; /** * Class Slug. @@ -23,18 +21,8 @@ protected function setUp(): void parent::setUp(); $this->required(); + $this->maxLength(192); $this->unique(ignoreRecord: true); - $this->rules([ - fn (?Model $record) => [ - 'required', - 'max:192', - 'alpha_dash', - $record !== null - ? Rule::unique($record::class, $this->getName()) - ->ignore($record->getKey(), $record->getKeyName()) - ->__toString() - : Rule::unique($this->getModel(), $this->getName())->__toString(), - ], - ]); + $this->alphaDash(); } } diff --git a/app/Http/Api/Field/List/Playlist/Track/TrackEntryIdField.php b/app/Http/Api/Field/List/Playlist/Track/TrackEntryIdField.php index 6e225f0fb..27f475f26 100644 --- a/app/Http/Api/Field/List/Playlist/Track/TrackEntryIdField.php +++ b/app/Http/Api/Field/List/Playlist/Track/TrackEntryIdField.php @@ -43,7 +43,6 @@ public function __construct(Schema $schema) public function getCreationRules(Request $request): array { return [ - 'sometimes', 'required', 'integer', Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID), @@ -90,8 +89,13 @@ public function getUpdateRules(Request $request): array 'required', 'integer', Rule::exists(AnimeThemeEntry::class, AnimeThemeEntry::ATTRIBUTE_ID), - Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY) - ->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $this->resolveVideoId($request)), + Rule::when( + ! empty($videoId), + [ + Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY) + ->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, $videoId), + ] + ), ]; } diff --git a/app/Http/Api/Field/List/Playlist/Track/TrackVideoIdField.php b/app/Http/Api/Field/List/Playlist/Track/TrackVideoIdField.php index f01bc15b9..f31d497ff 100644 --- a/app/Http/Api/Field/List/Playlist/Track/TrackVideoIdField.php +++ b/app/Http/Api/Field/List/Playlist/Track/TrackVideoIdField.php @@ -42,19 +42,12 @@ public function __construct(Schema $schema) */ public function getCreationRules(Request $request): array { - $entryId = $this->resolveEntryId($request); - return [ 'required', 'integer', Rule::exists(Video::class, Video::ATTRIBUTE_ID), - Rule::when( - ! empty($entryId), - [ - Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO) - ->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $this->resolveEntryId($request)), - ] - ), + Rule::exists(AnimeThemeEntryVideo::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO) + ->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, $this->resolveEntryId($request)), ]; } diff --git a/app/Http/Api/Schema/List/Playlist/TrackSchema.php b/app/Http/Api/Schema/List/Playlist/TrackSchema.php index e09ef8a83..66b25e6f9 100644 --- a/app/Http/Api/Schema/List/Playlist/TrackSchema.php +++ b/app/Http/Api/Schema/List/Playlist/TrackSchema.php @@ -58,10 +58,6 @@ public function allowedIncludes(): array new AllowedInclude(new TrackSchema(), PlaylistTrack::RELATION_NEXT), new AllowedInclude(new TrackSchema(), PlaylistTrack::RELATION_PREVIOUS), new AllowedInclude(new VideoSchema(), PlaylistTrack::RELATION_VIDEO), - - new AllowedInclude(new ArtistSchema(), 'video.animethemeentries.animetheme.song.artists'), - new AllowedInclude(new GroupSchema(), 'video.animethemeentries.animetheme.group'), - new AllowedInclude(new ImageSchema(), 'video.animethemeentries.animetheme.anime.images'), ]; } diff --git a/app/Http/Api/Schema/List/PlaylistSchema.php b/app/Http/Api/Schema/List/PlaylistSchema.php index 3aa638266..9446be0a6 100644 --- a/app/Http/Api/Schema/List/PlaylistSchema.php +++ b/app/Http/Api/Schema/List/PlaylistSchema.php @@ -59,14 +59,11 @@ public function allowedIncludes(): array new AllowedInclude(new TrackSchema(), Playlist::RELATION_TRACKS), new AllowedInclude(new UserSchema(), Playlist::RELATION_USER), - new AllowedInclude(new ArtistSchema(), 'tracks.video.animethemeentries.animetheme.song.artists'), new AllowedInclude(new ArtistSchema(), 'tracks.animethemeentry.animetheme.song.artists'), new AllowedInclude(new AudioSchema(), 'tracks.video.audio'), - new AllowedInclude(new ImageSchema(), 'tracks.video.animethemeentries.animetheme.anime.images'), new AllowedInclude(new EntrySchema(), 'tracks.animethemeentry'), new AllowedInclude(new ImageSchema(), 'tracks.animethemeentry.animetheme.anime.images'), new AllowedInclude(new VideoSchema(), 'tracks.video'), - new AllowedInclude(new GroupSchema(), 'tracks.video.animethemeentries.animetheme.group'), new AllowedInclude(new GroupSchema(), 'tracks.animethemeentry.animetheme.group'), new AllowedInclude(new TrackSchema(), 'tracks.previous'), new AllowedInclude(new TrackSchema(), 'tracks.next'),