diff --git a/app/Casts/SongStorageCast.php b/app/Casts/SongStorageCast.php index 15074f78..361a787b 100644 --- a/app/Casts/SongStorageCast.php +++ b/app/Casts/SongStorageCast.php @@ -15,10 +15,10 @@ class SongStorageCast implements CastsAttributes } /** @param SongStorageType|string|null $value */ - public function set(Model $model, string $key, mixed $value, array $attributes): string + public function set(Model $model, string $key, mixed $value, array $attributes): ?string { $type = $value instanceof SongStorageType ? $value : SongStorageType::tryFrom($value); - return $type->value; + return $type?->value; } } diff --git a/app/Repositories/SongRepository.php b/app/Repositories/SongRepository.php index 9c0dca8a..ab308d11 100644 --- a/app/Repositories/SongRepository.php +++ b/app/Repositories/SongRepository.php @@ -204,7 +204,7 @@ class SongRepository extends Repository */ public function getManyInCollaborativeContext(array $ids, ?User $scopedUser = null): Collection { - return Song::query(type: PlayableType::SONG, user: $scopedUser ?? $this->auth->user()) + return Song::query(user: $scopedUser ?? $this->auth->user()) ->accessible() ->withMeta() ->when(License::isPlus(), static function (SongBuilder $query): SongBuilder { diff --git a/database/factories/SongFactory.php b/database/factories/SongFactory.php index 044a250e..0514ea4e 100644 --- a/database/factories/SongFactory.php +++ b/database/factories/SongFactory.php @@ -47,6 +47,14 @@ class SongFactory extends Factory return $this->state(fn () => [ // @phpcs:ignore 'podcast_id' => Podcast::factory(), 'is_public' => true, + 'artist_id' => null, + 'owner_id' => null, + 'album_id' => null, + 'storage' => null, + 'path' => $this->faker->url(), + 'lyrics' => '', + 'track' => null, + 'disc' => 0, ]); } } diff --git a/tests/Integration/Services/PlaylistServiceTest.php b/tests/Integration/Services/PlaylistServiceTest.php index cf8597cf..3f589a53 100644 --- a/tests/Integration/Services/PlaylistServiceTest.php +++ b/tests/Integration/Services/PlaylistServiceTest.php @@ -4,6 +4,7 @@ namespace Tests\Integration\Services; use App\Models\Playlist; use App\Models\PlaylistFolder; +use App\Models\Podcast; use App\Models\Song; use App\Services\PlaylistService; use App\Values\SmartPlaylistRuleGroupCollection; @@ -210,7 +211,11 @@ class PlaylistServiceTest extends TestCase /** @var Playlist $playlist */ $playlist = Playlist::factory()->create(); $playlist->addPlayables(Song::factory(3)->create()); - $episodes = Song::factory(2)->asEpisode()->create(); + + $podcast = Podcast::factory()->create(); + $episodes = Song::factory(2)->asEpisode()->for($podcast)->create(); + + $playlist->user->subscribeToPodcast($podcast); $addedEpisodes = $this->service->addPlayablesToPlaylist($playlist, $episodes, $playlist->user); $playlist->refresh();