fix: added many-to-many generics & fix its keys (#946)

This commit is contained in:
Kyrch authored and GitHub committed 2025-09-01 09:43:45 -03:00
1 parent 3173c2818a
commit b220154cd3
35 files changed
+56 -253

No files matched your search

+4 -1
View File
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Contracts\Models;
use App\Models\Wiki\Image;
use App\Pivots\Morph\Imageable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
interface HasImages
@@ -13,7 +16,7 @@ interface HasImages
/**
* Get the images for the owner model.
*
* @return MorphToMany
* @return MorphToMany<Image, Model&HasImages, Imageable>
*/
public function images(): MorphToMany;
}
+4 -1
View File
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Contracts\Models;
use App\Models\Wiki\ExternalResource;
use App\Pivots\Morph\Resourceable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
interface HasResources
@@ -13,7 +16,7 @@ interface HasResources
/**
* Get the resources for the owner model.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, Model&HasResources, Resourceable>
*/
public function resources(): MorphToMany;
}
-4
View File
@@ -163,8 +163,6 @@ class ActionLog extends Model implements Nameable
}
/**
* Get the actionable.
*
* @return MorphTo
*/
public function actionable(): MorphTo
@@ -184,8 +182,6 @@ class ActionLog extends Model implements Nameable
}
/**
* Get the user that initiated the action.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
-4
View File
@@ -131,8 +131,6 @@ class FeaturedTheme extends BaseModel
}
/**
* Get the entry for the featured video.
*
* @return BelongsTo<AnimeThemeEntry, $this>
*/
public function animethemeentry(): BelongsTo
@@ -141,8 +139,6 @@ class FeaturedTheme extends BaseModel
}
/**
* Get the video to feature.
*
* @return BelongsTo<Video, $this>
*/
public function video(): BelongsTo
-2
View File
@@ -45,8 +45,6 @@ class LikeAggregate extends Model
public $timestamps = false;
/**
* Get the likeable of the aggregate.
*
* @return MorphTo
*/
public function likeable(): MorphTo
-2
View File
@@ -45,8 +45,6 @@ class ViewAggregate extends Model
public $timestamps = false;
/**
* Get the viewable of the aggregate.
*
* @return MorphTo
*/
public function viewable(): MorphTo
-9
View File
@@ -178,9 +178,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
|| $this->hasAnyPermission(SpecialPermission::BYPASS_AUTHORIZATION->value);
}
/**
* Get the filament avatar.
*/
public function getFilamentAvatarUrl(): string
{
$hash = md5(Str::lower(Str::trim($this->email)));
@@ -189,8 +186,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
}
/**
* Get the playlists that belong to the user.
*
* @return HasMany<Playlist, $this>
*/
public function playlists(): HasMany
@@ -199,8 +194,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
}
/**
* Get the playlists that belong to the user.
*
* @return HasMany<ExternalProfile, $this>
*/
public function externalprofiles(): HasMany
@@ -277,8 +270,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
}
/**
* Get the entity's notifications.
*
* @return MorphMany<Notification, $this>
*/
public function notifications(): MorphMany
-2
View File
@@ -101,8 +101,6 @@ class DiscordThread extends BaseModel
}
/**
* Gets the anime that the thread uses.
*
* @return BelongsTo<Anime, $this>
*/
public function anime(): BelongsTo
-4
View File
@@ -113,8 +113,6 @@ class ExternalEntry extends BaseModel
}
/**
* Get the anime that owns the user external entry.
*
* @return BelongsTo<Anime, $this>
*/
public function anime(): BelongsTo
@@ -123,8 +121,6 @@ class ExternalEntry extends BaseModel
}
/**
* Get the user profile that owns the user profile.
*
* @return BelongsTo<ExternalProfile, $this>
*/
public function externalprofile(): BelongsTo
-2
View File
@@ -93,8 +93,6 @@ class ExternalToken extends BaseModel
}
/**
* Get the external profile that owns the external token.
*
* @return BelongsTo<ExternalProfile, $this>
*/
public function externalprofile(): BelongsTo
+1 -14
View File
@@ -169,25 +169,18 @@ class ExternalProfile extends BaseModel
return (bool) $this->user_id;
}
/**
* Determine if the profile can be synced.
*/
public function canBeSynced(): bool
{
return ! $this->synced_at || $this->synced_at->addHours(3)->isPast();
}
/**
* Dispatch the sync external profile job.
*/
public function dispatchSyncJob(): void
{
SyncExternalProfileJob::dispatch($this);
}
/**
* Get the client URL for the profile.
* https://animethemes.moe/external/{mal|anilist}/{profile_name}.
* Format: https://animethemes.moe/external/{mal|anilist}/{profile_name}.
*/
public function getClientUrl(): string
{
@@ -200,8 +193,6 @@ class ExternalProfile extends BaseModel
}
/**
* Get the entries for the profile.
*
* @return HasMany<ExternalEntry, $this>
*/
public function externalentries(): HasMany
@@ -210,8 +201,6 @@ class ExternalProfile extends BaseModel
}
/**
* Get the user that owns the profile.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
@@ -220,8 +209,6 @@ class ExternalProfile extends BaseModel
}
/**
* Get the external token that the external profile owns.
*
* @return HasOne<ExternalToken, $this>
*/
public function externaltoken(): HasOne
+1 -11
View File
@@ -167,8 +167,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
}
/**
* Get the user that owns the playlist.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
@@ -177,8 +175,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
}
/**
* Get the first track of the playlist.
*
* @return BelongsTo<PlaylistTrack, $this>
*/
public function first(): BelongsTo
@@ -187,8 +183,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
}
/**
* Get the last track of the playlist.
*
* @return BelongsTo<PlaylistTrack, $this>
*/
public function last(): BelongsTo
@@ -197,9 +191,7 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
}
/**
* Get the images for the playlist.
*
* @return MorphToMany
* @return MorphToMany<Image, $this, Imageable, 'playlistimage'>
*/
public function images(): MorphToMany
{
@@ -210,8 +202,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
}
/**
* Get the tracks that comprise the playlist.
*
* @return HasMany<PlaylistTrack, $this>
*/
public function tracks(): HasMany
@@ -148,8 +148,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
}
/**
* Get the entry of the track.
*
* @return BelongsTo<AnimeThemeEntry, $this>
*/
public function animethemeentry(): BelongsTo
@@ -158,8 +156,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
}
/**
* Get the playlist the track belongs to.
*
* @return BelongsTo<Playlist, $this>
*/
public function playlist(): BelongsTo
@@ -168,8 +164,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
}
/**
* Get the previous track.
*
* @return BelongsTo<PlaylistTrack, $this>
*/
public function previous(): BelongsTo
@@ -178,8 +172,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
}
/**
* Get the next track.
*
* @return BelongsTo<PlaylistTrack, $this>
*/
public function next(): BelongsTo
@@ -188,8 +180,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
}
/**
* Get the video of the track.
*
* @return BelongsTo<Video, $this>
*/
public function video(): BelongsTo
-2
View File
@@ -35,8 +35,6 @@ class View extends BaseView
}
/**
* Get the user related to the view.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
-4
View File
@@ -102,8 +102,6 @@ class Encode extends BaseModel
}
/**
* Gets the user that owns the encode.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
@@ -112,8 +110,6 @@ class Encode extends BaseModel
}
/**
* Gets the video that owns the encode.
*
* @return BelongsTo<Video, $this>
*/
public function video(): BelongsTo
-7
View File
@@ -74,8 +74,6 @@ class Like extends BaseModel
}
/**
* Gets the user that owns the like.
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
@@ -83,11 +81,6 @@ class Like extends BaseModel
return $this->belongsTo(User::class, Like::ATTRIBUTE_USER);
}
/**
* Gets the video that owns the like.
*
* @return MorphTo
*/
public function likeable(): MorphTo
{
return $this->morphTo();
-2
View File
@@ -123,8 +123,6 @@ class Report extends BaseModel
}
/**
* Get the steps of the report.
*
* @return HasMany<ReportStep, $this>
*/
public function steps(): HasMany
-12
View File
@@ -152,29 +152,17 @@ class ReportStep extends BaseModel
return $newFields;
}
/**
* Get the actionable.
*
* @return MorphTo
*/
public function actionable(): MorphTo
{
return $this->morphTo();
}
/**
* Get the target of the action.
*
* @return MorphTo
*/
public function target(): MorphTo
{
return $this->morphTo();
}
/**
* Get the report the step belongs to.
*
* @return BelongsTo<Report, $this>
*/
public function report(): BelongsTo
+6 -22
View File
@@ -191,8 +191,6 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the synonyms for the anime.
*
* @return HasMany<AnimeSynonym, $this>
*/
public function animesynonyms(): HasMany
@@ -201,8 +199,6 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the discord thread that the anime owns.
*
* @return HasOne<DiscordThread, $this>
*/
public function discordthread(): HasOne
@@ -211,21 +207,17 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the series the anime is included in.
*
* @return BelongsToMany
* @return BelongsToMany<Series, $this, AnimeSeries>
*/
public function series(): BelongsToMany
{
return $this->belongsToMany(Series::class, AnimeSeries::TABLE, Anime::ATTRIBUTE_ID, Series::ATTRIBUTE_ID)
return $this->belongsToMany(Series::class, AnimeSeries::TABLE, AnimeSeries::ATTRIBUTE_ANIME, AnimeSeries::ATTRIBUTE_SERIES)
->using(AnimeSeries::class)
->as(AnimeSeriesResource::$wrap)
->withTimestamps();
}
/**
* Get the themes for the anime.
*
* @return HasMany<AnimeTheme, $this>
*/
public function animethemes(): HasMany
@@ -234,9 +226,7 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the resources for the anime through the resourceable morph pivot.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, $this, Resourceable, 'animeresource'>
*/
public function resources(): MorphToMany
{
@@ -248,9 +238,7 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the images for the anime.
*
* @return MorphToMany
* @return MorphToMany<Image, $this, Imageable, 'animeimage'>
*/
public function images(): MorphToMany
{
@@ -261,21 +249,17 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the studios that produced the anime.
*
* @return BelongsToMany
* @return BelongsToMany<Studio, $this, AnimeStudio>
*/
public function studios(): BelongsToMany
{
return $this->belongsToMany(Studio::class, AnimeStudio::TABLE, Anime::ATTRIBUTE_ID, Studio::ATTRIBUTE_ID)
return $this->belongsToMany(Studio::class, AnimeStudio::TABLE, AnimeStudio::ATTRIBUTE_ANIME, AnimeStudio::ATTRIBUTE_STUDIO)
->using(AnimeStudio::class)
->as(AnimeStudioResource::$wrap)
->withTimestamps();
}
/**
* Get the entries for the anime.
*
* @return HasMany<ExternalEntry, $this>
*/
public function externalentries(): HasMany
-2
View File
@@ -107,8 +107,6 @@ class AnimeSynonym extends BaseModel implements SoftDeletable
}
/**
* Gets the anime that owns the synonym.
*
* @return BelongsTo<Anime, $this>
*/
public function anime(): BelongsTo
-8
View File
@@ -192,8 +192,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable
}
/**
* Gets the anime that owns the theme.
*
* @return BelongsTo<Anime, $this>
*/
public function anime(): BelongsTo
@@ -202,8 +200,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable
}
/**
* Gets the group that the theme uses.
*
* @return BelongsTo<Group, $this>
*/
public function group(): BelongsTo
@@ -212,8 +208,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable
}
/**
* Gets the song that the theme uses.
*
* @return BelongsTo<Song, $this>
*/
public function song(): BelongsTo
@@ -222,8 +216,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable
}
/**
* Get the entries for the theme.
*
* @return HasMany<AnimeThemeEntry, $this>
*/
public function animethemeentries(): HasMany
@@ -200,8 +200,6 @@ class AnimeThemeEntry extends BaseModel implements HasResources, InteractsWithSc
}
/**
* Get the theme that owns the entry.
*
* @return BelongsTo<AnimeTheme, $this>
*/
public function animetheme(): BelongsTo
@@ -210,17 +208,15 @@ class AnimeThemeEntry extends BaseModel implements HasResources, InteractsWithSc
}
/**
* Get the videos linked in the theme entry.
*
* @return BelongsToMany
* @return BelongsToMany<Video, $this, AnimeThemeEntryVideo>
*/
public function videos(): BelongsToMany
{
return $this->belongsToMany(
Video::class,
AnimeThemeEntryVideo::class,
AnimeThemeEntry::ATTRIBUTE_ID,
Video::ATTRIBUTE_ID
AnimeThemeEntryVideo::ATTRIBUTE_ENTRY,
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO
)
->using(AnimeThemeEntryVideo::class)
->as(AnimeThemeEntryVideoResource::$wrap)
@@ -228,9 +224,7 @@ class AnimeThemeEntry extends BaseModel implements HasResources, InteractsWithSc
}
/**
* Get the resources for the entry through the resourceable morph pivot.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, $this, Resourceable, 'entryresource'>
*/
public function resources(): MorphToMany
{
+14 -22
View File
@@ -27,6 +27,7 @@ use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -156,13 +157,11 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the songs the artist has performed in.
*
* @return BelongsToMany
* @return BelongsToMany<Song, $this, ArtistSong>
*/
public function songs(): BelongsToMany
{
return $this->belongsToMany(Song::class, ArtistSong::TABLE, Artist::ATTRIBUTE_ID, Song::ATTRIBUTE_ID)
return $this->belongsToMany(Song::class, ArtistSong::TABLE, ArtistSong::ATTRIBUTE_ARTIST, ArtistSong::ATTRIBUTE_SONG)
->using(ArtistSong::class)
->withPivot([ArtistSong::ATTRIBUTE_ALIAS, ArtistSong::ATTRIBUTE_AS])
->as(ArtistSongResource::$wrap)
@@ -170,9 +169,7 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the performances of the artist.
*
* @return MorphMany
* @return MorphMany<Performance, $this>
*/
public function performances(): MorphMany
{
@@ -190,15 +187,16 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
->where(Performance::ATTRIBUTE_ARTIST_TYPE, Relation::getMorphAlias(Membership::class));
}
public function memberships()
/**
* @return HasMany<Membership, $this>
*/
public function memberships(): HasMany
{
return $this->hasMany(Membership::class, Membership::ATTRIBUTE_MEMBER);
}
/**
* Get the resources for the artist through the resourceable morph pivot.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, $this, Resourceable, 'artistresource'>
*/
public function resources(): MorphToMany
{
@@ -210,13 +208,11 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the members that comprise this group.
*
* @return BelongsToMany
* @return BelongsToMany<Artist, $this, ArtistMember>
*/
public function members(): BelongsToMany
{
return $this->belongsToMany(Artist::class, ArtistMember::TABLE, Artist::ATTRIBUTE_ID, 'member_id')
return $this->belongsToMany(Artist::class, ArtistMember::TABLE, ArtistMember::ATTRIBUTE_ARTIST, ArtistMember::ATTRIBUTE_MEMBER)
->using(ArtistMember::class)
->withPivot([ArtistMember::ATTRIBUTE_ALIAS, ArtistMember::ATTRIBUTE_AS, ArtistMember::ATTRIBUTE_NOTES])
->as(ArtistMemberResource::$wrap)
@@ -224,13 +220,11 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the groups the artist has performed in.
*
* @return BelongsToMany
* @return BelongsToMany<Artist, $this, ArtistMember>
*/
public function groups(): BelongsToMany
{
return $this->belongsToMany(Artist::class, ArtistMember::TABLE, 'member_id', Artist::ATTRIBUTE_ID)
return $this->belongsToMany(Artist::class, ArtistMember::TABLE, ArtistMember::ATTRIBUTE_MEMBER, ArtistMember::ATTRIBUTE_ARTIST)
->using(ArtistMember::class)
->withPivot([ArtistMember::ATTRIBUTE_ALIAS, ArtistMember::ATTRIBUTE_AS, ArtistMember::ATTRIBUTE_NOTES])
->as(ArtistMemberResource::$wrap)
@@ -238,9 +232,7 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the images for the artist.
*
* @return MorphToMany
* @return MorphToMany<Image, $this, Imageable, 'artistimage'>
*/
public function images(): MorphToMany
{
-5
View File
@@ -107,9 +107,6 @@ class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Strea
Audio::ATTRIBUTE_LINK,
];
/**
* The link of the audio.
*/
public function getLinkAttribute(): ?string
{
if ($this->hasAttribute($this->getRouteKeyName()) && $this->exists) {
@@ -172,8 +169,6 @@ class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Strea
}
/**
* Get the videos that use this audio.
*
* @return HasMany<Video, $this>
*/
public function videos(): HasMany
+5 -15
View File
@@ -117,9 +117,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
}
/**
* Get the anime that reference this resource.
*
* @return MorphToMany
* @return MorphToMany<Anime, $this, Resourceable, 'animeresource'>
*/
public function anime(): MorphToMany
{
@@ -131,9 +129,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
}
/**
* Get the entry that reference this resource.
*
* @return MorphToMany
* @return MorphToMany<AnimeThemeEntry, $this, Resourceable, 'entryresource'>
*/
public function animethemeentries(): MorphToMany
{
@@ -145,9 +141,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
}
/**
* Get the artists that reference this resource.
*
* @return MorphToMany
* @return MorphToMany<Artist, $this, Resourceable, 'artistresource'>
*/
public function artists(): MorphToMany
{
@@ -159,9 +153,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
}
/**
* Get the songs that reference this resource.
*
* @return MorphToMany
* @return MorphToMany<Song, $this, Resourceable, 'songresource'>
*/
public function songs(): MorphToMany
{
@@ -173,9 +165,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
}
/**
* Get the studios that reference this resource.
*
* @return MorphToMany
* @return MorphToMany<Studio, $this, Resourceable, 'studioresource'>
*/
public function studios(): MorphToMany
{
-2
View File
@@ -93,8 +93,6 @@ class Group extends BaseModel implements SoftDeletable
}
/**
* Get the themes for the group.
*
* @return HasMany<AnimeTheme, $this>
*/
public function animethemes(): HasMany
+4 -15
View File
@@ -127,9 +127,6 @@ class Image extends BaseModel implements SoftDeletable
return $this->path;
}
/**
* The link of the image model.
*/
public function getLinkAttribute(): ?string
{
if ($this->hasAttribute(Image::ATTRIBUTE_PATH) && $this->exists) {
@@ -143,9 +140,7 @@ class Image extends BaseModel implements SoftDeletable
}
/**
* Get the anime that use this image.
*
* @return MorphToMany
* @return MorphToMany<Anime, $this, Imageable, 'animeimage'>
*/
public function anime(): MorphToMany
{
@@ -156,9 +151,7 @@ class Image extends BaseModel implements SoftDeletable
}
/**
* Get the artists that use this image.
*
* @return MorphToMany
* @return MorphToMany<Artist, $this, Imageable, 'artistimage'>
*/
public function artists(): MorphToMany
{
@@ -170,9 +163,7 @@ class Image extends BaseModel implements SoftDeletable
}
/**
* Get the studios that use this image.
*
* @return MorphToMany
* @return MorphToMany<Studio, $this, Imageable, 'studioimage'>
*/
public function studios(): MorphToMany
{
@@ -183,9 +174,7 @@ class Image extends BaseModel implements SoftDeletable
}
/**
* Get the playlists that use this image.
*
* @return MorphToMany
* @return MorphToMany<Playlist, $this, Imageable, 'playlistimage'>
*/
public function playlists(): MorphToMany
{
+2 -4
View File
@@ -130,13 +130,11 @@ class Series extends BaseModel implements SoftDeletable
}
/**
* Get the anime included in the series.
*
* @return BelongsToMany
* @return BelongsToMany<Anime, $this, AnimeSeries>
*/
public function anime(): BelongsToMany
{
return $this->belongsToMany(Anime::class, AnimeSeries::TABLE, Series::ATTRIBUTE_ID, Anime::ATTRIBUTE_ID)
return $this->belongsToMany(Anime::class, AnimeSeries::TABLE, AnimeSeries::ATTRIBUTE_SERIES, AnimeSeries::ATTRIBUTE_ANIME)
->using(AnimeSeries::class)
->as(AnimeSeriesResource::$wrap)
->withTimestamps();
+3 -11
View File
@@ -113,8 +113,6 @@ class Song extends BaseModel implements HasResources, SoftDeletable
}
/**
* Get the anime themes that use this song.
*
* @return HasMany<AnimeTheme, $this>
*/
public function animethemes(): HasMany
@@ -123,13 +121,11 @@ class Song extends BaseModel implements HasResources, SoftDeletable
}
/**
* Get the artists included in the performance.
*
* @return BelongsToMany
* @return BelongsToMany<Artist, $this, ArtistSong>
*/
public function artists(): BelongsToMany
{
return $this->belongsToMany(Artist::class, ArtistSong::TABLE, Song::ATTRIBUTE_ID, Artist::ATTRIBUTE_ID)
return $this->belongsToMany(Artist::class, ArtistSong::TABLE, ArtistSong::ATTRIBUTE_SONG, ArtistSong::ATTRIBUTE_ARTIST)
->using(ArtistSong::class)
->withPivot([ArtistSong::ATTRIBUTE_ALIAS, ArtistSong::ATTRIBUTE_AS])
->as(ArtistSongResource::$wrap)
@@ -137,8 +133,6 @@ class Song extends BaseModel implements HasResources, SoftDeletable
}
/**
* Get the performances of the song.
*
* @return HasMany<Performance, $this>
*/
public function performances(): HasMany
@@ -147,9 +141,7 @@ class Song extends BaseModel implements HasResources, SoftDeletable
}
/**
* Get the resources for the song through the resourceable morph pivot.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, $this, Resourceable, 'songresource'>
*/
public function resources(): MorphToMany
{
+1 -7
View File
@@ -102,8 +102,6 @@ class Membership extends BaseModel implements SoftDeletable
}
/**
* Get the group that owns the membership.
*
* @return BelongsTo<Artist, $this>
*/
public function group(): BelongsTo
@@ -112,8 +110,6 @@ class Membership extends BaseModel implements SoftDeletable
}
/**
* Get the member that owns the membership.
*
* @return BelongsTo<Artist, $this>
*/
public function member(): BelongsTo
@@ -122,9 +118,7 @@ class Membership extends BaseModel implements SoftDeletable
}
/**
* Get the performances of the membership.
*
* @return MorphMany
* @return MorphMany<Performance, $this>
*/
public function performances(): MorphMany
{
-7
View File
@@ -104,17 +104,12 @@ class Performance extends BaseModel implements SoftDeletable
return $this->song->getName();
}
/**
* Determine if the performance is a membership.
*/
public function isMembership(): bool
{
return $this->artist_type === Relation::getMorphAlias(Membership::class);
}
/**
* Get the song that owns the performance.
*
* @return BelongsTo<Song, $this>
*/
public function song(): BelongsTo
@@ -123,8 +118,6 @@ class Performance extends BaseModel implements SoftDeletable
}
/**
* Get the artist that owns the performance.
*
* @return MorphTo
*/
public function artist(): MorphTo
+4 -10
View File
@@ -110,22 +110,18 @@ class Studio extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the anime that the studio produced.
*
* @return BelongsToMany
* @return BelongsToMany<Anime, $this, AnimeStudio>
*/
public function anime(): BelongsToMany
{
return $this->belongsToMany(Anime::class, AnimeStudio::TABLE, Studio::ATTRIBUTE_ID, Anime::ATTRIBUTE_ID)
return $this->belongsToMany(Anime::class, AnimeStudio::TABLE, AnimeStudio::ATTRIBUTE_STUDIO, AnimeStudio::ATTRIBUTE_ANIME)
->using(AnimeStudio::class)
->as(AnimeStudioResource::$wrap)
->withTimestamps();
}
/**
* Get the resources for the studio through the resourceable morph pivot.
*
* @return MorphToMany
* @return MorphToMany<ExternalResource, $this, Resourceable, 'studioresource'>
*/
public function resources(): MorphToMany
{
@@ -137,9 +133,7 @@ class Studio extends BaseModel implements HasImages, HasResources, SoftDeletable
}
/**
* Get the images for the studio.
*
* @return MorphToMany
* @return MorphToMany<Image, $this, Imageable, 'studioimage'>
*/
public function images(): MorphToMany
{
+2 -15
View File
@@ -167,9 +167,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
Video::ATTRIBUTE_TAGS,
];
/**
* The link of the video.
*/
public function getLinkAttribute(): ?string
{
if ($this->hasAttribute($this->getRouteKeyName()) && $this->exists) {
@@ -322,21 +319,17 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
}
/**
* Get the related entries.
*
* @return BelongsToMany
* @return BelongsToMany<AnimeThemeEntry, $this, AnimeThemeEntryVideo>
*/
public function animethemeentries(): BelongsToMany
{
return $this->belongsToMany(AnimeThemeEntry::class, AnimeThemeEntryVideo::TABLE, Video::ATTRIBUTE_ID, AnimeThemeEntry::ATTRIBUTE_ID)
return $this->belongsToMany(AnimeThemeEntry::class, AnimeThemeEntryVideo::TABLE, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
->using(AnimeThemeEntryVideo::class)
->as(AnimeThemeEntryVideoResource::$wrap)
->withTimestamps();
}
/**
* Gets the audio that the video uses.
*
* @return BelongsTo<Audio, $this>
*/
public function audio(): BelongsTo
@@ -345,8 +338,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
}
/**
* Get the script that the video owns.
*
* @return HasOne<VideoScript, $this>
*/
public function videoscript(): HasOne
@@ -355,8 +346,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
}
/**
* Get the tracks that use this video.
*
* @return HasMany<PlaylistTrack, $this>
*/
public function tracks(): HasMany
@@ -366,8 +355,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L
}
/**
* Get the encodes of the video.
*
* @return HasMany<Encode, $this>
*/
public function encodes(): HasMany
-5
View File
@@ -90,9 +90,6 @@ class VideoScript extends BaseModel implements InteractsWithSchema, SoftDeletabl
VideoScript::ATTRIBUTE_LINK,
];
/**
* The link of the video script.
*/
public function getLinkAttribute(): ?string
{
// Necessary for 'make' factories.
@@ -114,8 +111,6 @@ class VideoScript extends BaseModel implements InteractsWithSchema, SoftDeletabl
}
/**
* Get the video that owns the script.
*
* @return BelongsTo<Video, $this>
*/
public function video(): BelongsTo
+1
View File
@@ -29,6 +29,7 @@ parameters:
- '#Call to an undefined method Database\\Factories.*::trashed\(\).#'
- '#::mapWithKeys\(\) expects*non-empty-array<int\|string, string> given.#'
- '#Access to an undefined property App\\Models\\Wiki\\Artist::\$pivot.#'
- "#BelongsToMany<.*,\\s*'pivot'> but returns .*BelongsToMany<.*,\\s*string>.#"
- '#Call to method assertActionMounted\(\) on an unknown class static.#'
-
message: '#Call to an undefined method PHPUnit\\Framework\\TestCase::.*\(\)#'