Skip to content

Commit

Permalink
clean: removed old track entry_id stuff (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Aug 20, 2024
1 parent 70d3253 commit cab98d8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 33 deletions.
16 changes: 2 additions & 14 deletions app/Filament/Components/Fields/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
}
}
10 changes: 7 additions & 3 deletions app/Http/Api/Field/List/Playlist/Track/TrackEntryIdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
]
),
];
}

Expand Down
11 changes: 2 additions & 9 deletions app/Http/Api/Field/List/Playlist/Track/TrackVideoIdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
];
}

Expand Down
4 changes: 0 additions & 4 deletions app/Http/Api/Schema/List/Playlist/TrackSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
];
}

Expand Down
3 changes: 0 additions & 3 deletions app/Http/Api/Schema/List/PlaylistSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit cab98d8

Please sign in to comment.