diff --git a/app/Contracts/Models/HasImages.php b/app/Contracts/Models/HasImages.php index 4b9b32741..de64a6ea4 100644 --- a/app/Contracts/Models/HasImages.php +++ b/app/Contracts/Models/HasImages.php @@ -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 */ public function images(): MorphToMany; } diff --git a/app/Contracts/Models/HasResources.php b/app/Contracts/Models/HasResources.php index e879ca069..0c4629b08 100644 --- a/app/Contracts/Models/HasResources.php +++ b/app/Contracts/Models/HasResources.php @@ -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 */ public function resources(): MorphToMany; } diff --git a/app/Models/Admin/ActionLog.php b/app/Models/Admin/ActionLog.php index 88412bc63..70cacc4d1 100644 --- a/app/Models/Admin/ActionLog.php +++ b/app/Models/Admin/ActionLog.php @@ -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 */ public function user(): BelongsTo diff --git a/app/Models/Admin/FeaturedTheme.php b/app/Models/Admin/FeaturedTheme.php index b8864816d..e5614cff2 100644 --- a/app/Models/Admin/FeaturedTheme.php +++ b/app/Models/Admin/FeaturedTheme.php @@ -131,8 +131,6 @@ class FeaturedTheme extends BaseModel } /** - * Get the entry for the featured video. - * * @return BelongsTo */ public function animethemeentry(): BelongsTo @@ -141,8 +139,6 @@ class FeaturedTheme extends BaseModel } /** - * Get the video to feature. - * * @return BelongsTo */ public function video(): BelongsTo diff --git a/app/Models/Aggregate/LikeAggregate.php b/app/Models/Aggregate/LikeAggregate.php index 86f35dea2..1f48cdc87 100644 --- a/app/Models/Aggregate/LikeAggregate.php +++ b/app/Models/Aggregate/LikeAggregate.php @@ -45,8 +45,6 @@ class LikeAggregate extends Model public $timestamps = false; /** - * Get the likeable of the aggregate. - * * @return MorphTo */ public function likeable(): MorphTo diff --git a/app/Models/Aggregate/ViewAggregate.php b/app/Models/Aggregate/ViewAggregate.php index b9a37ab0e..e54a26258 100644 --- a/app/Models/Aggregate/ViewAggregate.php +++ b/app/Models/Aggregate/ViewAggregate.php @@ -45,8 +45,6 @@ class ViewAggregate extends Model public $timestamps = false; /** - * Get the viewable of the aggregate. - * * @return MorphTo */ public function viewable(): MorphTo diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index 04f41c8f7..1eda3230a 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -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 */ 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 */ public function externalprofiles(): HasMany @@ -277,8 +270,6 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit } /** - * Get the entity's notifications. - * * @return MorphMany */ public function notifications(): MorphMany diff --git a/app/Models/Discord/DiscordThread.php b/app/Models/Discord/DiscordThread.php index 38603a313..7532d1e18 100644 --- a/app/Models/Discord/DiscordThread.php +++ b/app/Models/Discord/DiscordThread.php @@ -101,8 +101,6 @@ class DiscordThread extends BaseModel } /** - * Gets the anime that the thread uses. - * * @return BelongsTo */ public function anime(): BelongsTo diff --git a/app/Models/List/External/ExternalEntry.php b/app/Models/List/External/ExternalEntry.php index e26e2ef22..f77a04c07 100644 --- a/app/Models/List/External/ExternalEntry.php +++ b/app/Models/List/External/ExternalEntry.php @@ -113,8 +113,6 @@ class ExternalEntry extends BaseModel } /** - * Get the anime that owns the user external entry. - * * @return BelongsTo */ public function anime(): BelongsTo @@ -123,8 +121,6 @@ class ExternalEntry extends BaseModel } /** - * Get the user profile that owns the user profile. - * * @return BelongsTo */ public function externalprofile(): BelongsTo diff --git a/app/Models/List/External/ExternalToken.php b/app/Models/List/External/ExternalToken.php index 92e71b76a..d24bfa9a5 100644 --- a/app/Models/List/External/ExternalToken.php +++ b/app/Models/List/External/ExternalToken.php @@ -93,8 +93,6 @@ class ExternalToken extends BaseModel } /** - * Get the external profile that owns the external token. - * * @return BelongsTo */ public function externalprofile(): BelongsTo diff --git a/app/Models/List/ExternalProfile.php b/app/Models/List/ExternalProfile.php index accbd6f06..8ba6e5495 100644 --- a/app/Models/List/ExternalProfile.php +++ b/app/Models/List/ExternalProfile.php @@ -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 */ public function externalentries(): HasMany @@ -210,8 +201,6 @@ class ExternalProfile extends BaseModel } /** - * Get the user that owns the profile. - * * @return BelongsTo */ public function user(): BelongsTo @@ -220,8 +209,6 @@ class ExternalProfile extends BaseModel } /** - * Get the external token that the external profile owns. - * * @return HasOne */ public function externaltoken(): HasOne diff --git a/app/Models/List/Playlist.php b/app/Models/List/Playlist.php index e8215c191..90854d2c0 100644 --- a/app/Models/List/Playlist.php +++ b/app/Models/List/Playlist.php @@ -167,8 +167,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm } /** - * Get the user that owns the playlist. - * * @return BelongsTo */ 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 */ 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 */ 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 */ 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 */ public function tracks(): HasMany diff --git a/app/Models/List/Playlist/PlaylistTrack.php b/app/Models/List/Playlist/PlaylistTrack.php index db68f90bd..68ec38359 100644 --- a/app/Models/List/Playlist/PlaylistTrack.php +++ b/app/Models/List/Playlist/PlaylistTrack.php @@ -148,8 +148,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema } /** - * Get the entry of the track. - * * @return BelongsTo */ public function animethemeentry(): BelongsTo @@ -158,8 +156,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema } /** - * Get the playlist the track belongs to. - * * @return BelongsTo */ public function playlist(): BelongsTo @@ -168,8 +164,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema } /** - * Get the previous track. - * * @return BelongsTo */ public function previous(): BelongsTo @@ -178,8 +172,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema } /** - * Get the next track. - * * @return BelongsTo */ public function next(): BelongsTo @@ -188,8 +180,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema } /** - * Get the video of the track. - * * @return BelongsTo */ public function video(): BelongsTo diff --git a/app/Models/Service/View.php b/app/Models/Service/View.php index 85ccb9e6e..cd863173a 100644 --- a/app/Models/Service/View.php +++ b/app/Models/Service/View.php @@ -35,8 +35,6 @@ class View extends BaseView } /** - * Get the user related to the view. - * * @return BelongsTo */ public function user(): BelongsTo diff --git a/app/Models/User/Encode.php b/app/Models/User/Encode.php index ac919ac71..1e3c8713d 100644 --- a/app/Models/User/Encode.php +++ b/app/Models/User/Encode.php @@ -102,8 +102,6 @@ class Encode extends BaseModel } /** - * Gets the user that owns the encode. - * * @return BelongsTo */ public function user(): BelongsTo @@ -112,8 +110,6 @@ class Encode extends BaseModel } /** - * Gets the video that owns the encode. - * * @return BelongsTo */ public function video(): BelongsTo diff --git a/app/Models/User/Like.php b/app/Models/User/Like.php index cf6bc50fe..f5370fd56 100644 --- a/app/Models/User/Like.php +++ b/app/Models/User/Like.php @@ -74,8 +74,6 @@ class Like extends BaseModel } /** - * Gets the user that owns the like. - * * @return BelongsTo */ 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(); diff --git a/app/Models/User/Report.php b/app/Models/User/Report.php index 189b93637..761cf7945 100644 --- a/app/Models/User/Report.php +++ b/app/Models/User/Report.php @@ -123,8 +123,6 @@ class Report extends BaseModel } /** - * Get the steps of the report. - * * @return HasMany */ public function steps(): HasMany diff --git a/app/Models/User/Report/ReportStep.php b/app/Models/User/Report/ReportStep.php index e12c6e5d2..651dc64c8 100644 --- a/app/Models/User/Report/ReportStep.php +++ b/app/Models/User/Report/ReportStep.php @@ -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 */ public function report(): BelongsTo diff --git a/app/Models/Wiki/Anime.php b/app/Models/Wiki/Anime.php index 4c6bcfa17..17deb5486 100644 --- a/app/Models/Wiki/Anime.php +++ b/app/Models/Wiki/Anime.php @@ -191,8 +191,6 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable } /** - * Get the synonyms for the anime. - * * @return HasMany */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ public function externalentries(): HasMany diff --git a/app/Models/Wiki/Anime/AnimeSynonym.php b/app/Models/Wiki/Anime/AnimeSynonym.php index 2c41e9b98..ae581f4ac 100644 --- a/app/Models/Wiki/Anime/AnimeSynonym.php +++ b/app/Models/Wiki/Anime/AnimeSynonym.php @@ -107,8 +107,6 @@ class AnimeSynonym extends BaseModel implements SoftDeletable } /** - * Gets the anime that owns the synonym. - * * @return BelongsTo */ public function anime(): BelongsTo diff --git a/app/Models/Wiki/Anime/AnimeTheme.php b/app/Models/Wiki/Anime/AnimeTheme.php index a365634fd..a8fda34bc 100644 --- a/app/Models/Wiki/Anime/AnimeTheme.php +++ b/app/Models/Wiki/Anime/AnimeTheme.php @@ -192,8 +192,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable } /** - * Gets the anime that owns the theme. - * * @return BelongsTo */ public function anime(): BelongsTo @@ -202,8 +200,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable } /** - * Gets the group that the theme uses. - * * @return BelongsTo */ public function group(): BelongsTo @@ -212,8 +208,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable } /** - * Gets the song that the theme uses. - * * @return BelongsTo */ public function song(): BelongsTo @@ -222,8 +216,6 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable } /** - * Get the entries for the theme. - * * @return HasMany */ public function animethemeentries(): HasMany diff --git a/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php b/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php index b705c23b3..b7b2fb987 100644 --- a/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php +++ b/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php @@ -200,8 +200,6 @@ class AnimeThemeEntry extends BaseModel implements HasResources, InteractsWithSc } /** - * Get the theme that owns the entry. - * * @return BelongsTo */ 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 */ 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 */ public function resources(): MorphToMany { diff --git a/app/Models/Wiki/Artist.php b/app/Models/Wiki/Artist.php index ffdd1da51..f33e16445 100644 --- a/app/Models/Wiki/Artist.php +++ b/app/Models/Wiki/Artist.php @@ -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 */ 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 */ 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 + */ + 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 */ 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 */ 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 */ 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 */ public function images(): MorphToMany { diff --git a/app/Models/Wiki/Audio.php b/app/Models/Wiki/Audio.php index c7643f356..e67cee8c4 100644 --- a/app/Models/Wiki/Audio.php +++ b/app/Models/Wiki/Audio.php @@ -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 */ public function videos(): HasMany diff --git a/app/Models/Wiki/ExternalResource.php b/app/Models/Wiki/ExternalResource.php index 16eb71ddf..a5ec082e0 100644 --- a/app/Models/Wiki/ExternalResource.php +++ b/app/Models/Wiki/ExternalResource.php @@ -117,9 +117,7 @@ class ExternalResource extends BaseModel implements SoftDeletable } /** - * Get the anime that reference this resource. - * - * @return MorphToMany + * @return MorphToMany */ 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 */ 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 */ 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 */ 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 */ public function studios(): MorphToMany { diff --git a/app/Models/Wiki/Group.php b/app/Models/Wiki/Group.php index 74cdb7f97..7facba856 100644 --- a/app/Models/Wiki/Group.php +++ b/app/Models/Wiki/Group.php @@ -93,8 +93,6 @@ class Group extends BaseModel implements SoftDeletable } /** - * Get the themes for the group. - * * @return HasMany */ public function animethemes(): HasMany diff --git a/app/Models/Wiki/Image.php b/app/Models/Wiki/Image.php index 950775be1..c9d427b18 100644 --- a/app/Models/Wiki/Image.php +++ b/app/Models/Wiki/Image.php @@ -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 */ 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 */ 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 */ 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 */ public function playlists(): MorphToMany { diff --git a/app/Models/Wiki/Series.php b/app/Models/Wiki/Series.php index 6cbbb6cdd..e2d1b3ebe 100644 --- a/app/Models/Wiki/Series.php +++ b/app/Models/Wiki/Series.php @@ -130,13 +130,11 @@ class Series extends BaseModel implements SoftDeletable } /** - * Get the anime included in the series. - * - * @return BelongsToMany + * @return BelongsToMany */ 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(); diff --git a/app/Models/Wiki/Song.php b/app/Models/Wiki/Song.php index 60f3c7d2e..73bb30d81 100644 --- a/app/Models/Wiki/Song.php +++ b/app/Models/Wiki/Song.php @@ -113,8 +113,6 @@ class Song extends BaseModel implements HasResources, SoftDeletable } /** - * Get the anime themes that use this song. - * * @return HasMany */ 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 */ 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 */ 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 */ public function resources(): MorphToMany { diff --git a/app/Models/Wiki/Song/Membership.php b/app/Models/Wiki/Song/Membership.php index d8c8b077b..9f7a8486a 100644 --- a/app/Models/Wiki/Song/Membership.php +++ b/app/Models/Wiki/Song/Membership.php @@ -102,8 +102,6 @@ class Membership extends BaseModel implements SoftDeletable } /** - * Get the group that owns the membership. - * * @return BelongsTo */ public function group(): BelongsTo @@ -112,8 +110,6 @@ class Membership extends BaseModel implements SoftDeletable } /** - * Get the member that owns the membership. - * * @return BelongsTo */ public function member(): BelongsTo @@ -122,9 +118,7 @@ class Membership extends BaseModel implements SoftDeletable } /** - * Get the performances of the membership. - * - * @return MorphMany + * @return MorphMany */ public function performances(): MorphMany { diff --git a/app/Models/Wiki/Song/Performance.php b/app/Models/Wiki/Song/Performance.php index 495ab8297..da1a78c15 100644 --- a/app/Models/Wiki/Song/Performance.php +++ b/app/Models/Wiki/Song/Performance.php @@ -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 */ 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 diff --git a/app/Models/Wiki/Studio.php b/app/Models/Wiki/Studio.php index 6923f85ab..cf9c21ccc 100644 --- a/app/Models/Wiki/Studio.php +++ b/app/Models/Wiki/Studio.php @@ -110,22 +110,18 @@ class Studio extends BaseModel implements HasImages, HasResources, SoftDeletable } /** - * Get the anime that the studio produced. - * - * @return BelongsToMany + * @return BelongsToMany */ 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 */ 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 */ public function images(): MorphToMany { diff --git a/app/Models/Wiki/Video.php b/app/Models/Wiki/Video.php index abfda5b46..3a8d68fed 100644 --- a/app/Models/Wiki/Video.php +++ b/app/Models/Wiki/Video.php @@ -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 */ 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 */ 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 */ 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 */ public function tracks(): HasMany @@ -366,8 +355,6 @@ class Video extends BaseModel implements HasAggregateLikes, HasAggregateViews, L } /** - * Get the encodes of the video. - * * @return HasMany */ public function encodes(): HasMany diff --git a/app/Models/Wiki/Video/VideoScript.php b/app/Models/Wiki/Video/VideoScript.php index 441a831e3..1c204bc1e 100644 --- a/app/Models/Wiki/Video/VideoScript.php +++ b/app/Models/Wiki/Video/VideoScript.php @@ -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 */ public function video(): BelongsTo diff --git a/phpstan.neon b/phpstan.neon index 640428b91..2996b56b3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,6 +29,7 @@ parameters: - '#Call to an undefined method Database\\Factories.*::trashed\(\).#' - '#::mapWithKeys\(\) expects*non-empty-array 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::.*\(\)#'