Skip to content

Commit

Permalink
refactor: changed theme_group relationship name and removed group fie…
Browse files Browse the repository at this point in the history
…ld (#664)
  • Loading branch information
Kyrch authored Apr 30, 2024
1 parent 811e867 commit 1744b54
Show file tree
Hide file tree
Showing 32 changed files with 103 additions and 138 deletions.
2 changes: 1 addition & 1 deletion app/Events/Wiki/Group/GroupDeleting.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function updateRelatedIndices(): void
if ($group->isForceDeleting()) {
$group->animethemes->each(function (AnimeTheme $theme) {
AnimeTheme::withoutEvents(function () use ($theme) {
$theme->theme_group()->dissociate();
$theme->group()->dissociate();
$theme->save();
});
$theme->searchable();
Expand Down
60 changes: 0 additions & 60 deletions app/Http/Api/Field/Wiki/Anime/Theme/ThemeGroupField.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Api/Field/Wiki/Anime/Theme/ThemeGroupIdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ThemeGroupIdField extends Field implements CreatableField, UpdatableField,
*/
public function __construct(Schema $schema)
{
parent::__construct($schema, AnimeTheme::ATTRIBUTE_THEME_GROUP);
parent::__construct($schema, AnimeTheme::ATTRIBUTE_GROUP);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/Admin/FeaturedThemeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function allowedIncludes(): array
new AllowedInclude(new UserSchema(), FeaturedTheme::RELATION_USER),
new AllowedInclude(new VideoSchema(), FeaturedTheme::RELATION_VIDEO),

new AllowedInclude(new GroupSchema(), 'animethemeentry.animetheme.theme_group'),
new AllowedInclude(new GroupSchema(), 'animethemeentry.animetheme.group'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/List/Playlist/TrackSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function allowedIncludes(): array
new AllowedInclude(new TrackSchema(), PlaylistTrack::RELATION_PREVIOUS),
new AllowedInclude(new VideoSchema(), PlaylistTrack::RELATION_VIDEO),

new AllowedInclude(new GroupSchema(), 'video.animethemeentries.animetheme.theme_group'),
new AllowedInclude(new GroupSchema(), 'video.animethemeentries.animetheme.group'),
];
}

Expand Down
2 changes: 0 additions & 2 deletions app/Http/Api/Schema/Wiki/Anime/ThemeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Http\Api\Field\Base\IdField;
use App\Http\Api\Field\Field;
use App\Http\Api\Field\Wiki\Anime\Theme\ThemeAnimeIdField;
use App\Http\Api\Field\Wiki\Anime\Theme\ThemeGroupField;
use App\Http\Api\Field\Wiki\Anime\Theme\ThemeGroupIdField;
use App\Http\Api\Field\Wiki\Anime\Theme\ThemeSequenceField;
use App\Http\Api\Field\Wiki\Anime\Theme\ThemeSlugField;
Expand Down Expand Up @@ -81,7 +80,6 @@ public function fields(): array
parent::fields(),
[
new IdField($this, AnimeTheme::ATTRIBUTE_ID),
new ThemeGroupField($this),
new ThemeSequenceField($this),
new ThemeSlugField($this),
new ThemeTypeField($this),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/Wiki/AnimeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function allowedIncludes(): array
new AllowedInclude(new VideoSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.animethemeentries.videos'),
new AllowedInclude(new AudioSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.animethemeentries.videos.audio'),
new AllowedInclude(new ArtistSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.song.artists'),
new AllowedInclude(new GroupSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.theme_group'),
new AllowedInclude(new GroupSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.group'),
new AllowedInclude(new ExternalResourceSchema(), 'animethemes.animethemeentries.videos.animethemeentries.animetheme.song.resources'),
new AllowedInclude(new ExternalResourceSchema(), 'animethemes.song.resources'),
new AllowedInclude(new ImageSchema(), 'animethemes.song.artists.images'),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/Wiki/SeriesSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function allowedIncludes(): array
// Undocumented paths needed for client builds
new AllowedInclude(new ImageSchema(), 'anime.images'),
new AllowedInclude(new VideoSchema(), 'anime.animethemes.animethemeentries.videos'),
new AllowedInclude(new GroupSchema(), 'anime.animethemes.theme_group'),
new AllowedInclude(new GroupSchema(), 'anime.animethemes.group'),
new AllowedInclude(new SongSchema(), 'anime.animethemes.song'),
];
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Api/Schema/Wiki/SongSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function allowedIncludes(): array
new AllowedInclude(new AnimeSchema(), Song::RELATION_ANIME),
new AllowedInclude(new ArtistSchema(), Song::RELATION_ARTISTS),
new AllowedInclude(new ExternalResourceSchema(), Song::RELATION_RESOURCES),
new AllowedInclude(new GroupSchema(), Song::RELATION_THEME_GROUPS),
new AllowedInclude(new ThemeSchema(), Song::RELATION_ANIMETHEMES),
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/Wiki/StudioSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function allowedIncludes(): array
new AllowedInclude(new ImageSchema(), 'anime.images'),
new AllowedInclude(new VideoSchema(), 'anime.animethemes.animethemeentries.videos'),
new AllowedInclude(new SongSchema(), 'anime.animethemes.song'),
new AllowedInclude(new GroupSchema(), 'anime.animethemes.theme_group'),
new AllowedInclude(new GroupSchema(), 'anime.animethemes.group'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Api/Schema/Wiki/VideoSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function allowedIncludes(): array
new AllowedInclude(new AnimeSchema(), Video::RELATION_ANIME),
new AllowedInclude(new AudioSchema(), Video::RELATION_AUDIO),
new AllowedInclude(new EntrySchema(), Video::RELATION_ANIMETHEMEENTRIES),
new AllowedInclude(new GroupSchema(), Video::RELATION_GROUP),
new AllowedInclude(new ScriptSchema(), Video::RELATION_SCRIPT),
new AllowedInclude(new ThemeSchema(), Video::RELATION_ANIMETHEME),
new AllowedInclude(new TrackSchema(), Video::RELATION_TRACKS),

// Undocumented paths needed for client builds
new AllowedInclude(new SongSchema(), 'animethemeentries.animetheme.song'),
new AllowedInclude(new ArtistSchema(), 'animethemeentries.animetheme.song.artists'),
new AllowedInclude(new GroupSchema(), 'animethemeentries.animetheme.theme_group'),
new AllowedInclude(new ImageSchema(), 'animethemeentries.animetheme.anime.images'),
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Wiki/Anime.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Anime extends BaseModel
final public const RELATION_ARTISTS = 'animethemes.song.artists';
final public const RELATION_AUDIO = 'animethemes.animethemeentries.videos.audio';
final public const RELATION_ENTRIES = 'animethemes.animethemeentries';
final public const RELATION_GROUPS = 'animethemes.theme_group';
final public const RELATION_GROUPS = 'animethemes.group';
final public const RELATION_IMAGES = 'images';
final public const RELATION_RESOURCES = 'resources';
final public const RELATION_SCRIPTS = 'animethemes.animethemeentries.videos.videoscript';
Expand Down
13 changes: 5 additions & 8 deletions app/Models/Wiki/Anime/AnimeTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
* @property Anime $anime
* @property int $anime_id
* @property Collection<int, AnimeThemeEntry> $animethemeentries
* @property string|null $group
* @property Group|null $theme_group
* @property Group|null $group
* @property int|null $group_id
* @property int|null $sequence
* @property string $slug
Expand All @@ -49,19 +48,18 @@ class AnimeTheme extends BaseModel
final public const TABLE = 'anime_themes';

final public const ATTRIBUTE_ANIME = 'anime_id';
final public const ATTRIBUTE_GROUP = 'group';
final public const ATTRIBUTE_ID = 'theme_id';
final public const ATTRIBUTE_GROUP = 'group_id';
final public const ATTRIBUTE_SEQUENCE = 'sequence';
final public const ATTRIBUTE_SLUG = 'slug';
final public const ATTRIBUTE_SONG = 'song_id';
final public const ATTRIBUTE_THEME_GROUP = 'group_id';
final public const ATTRIBUTE_TYPE = 'type';

final public const RELATION_ANIME = 'anime';
final public const RELATION_ARTISTS = 'song.artists';
final public const RELATION_AUDIO = 'animethemeentries.videos.audio';
final public const RELATION_ENTRIES = 'animethemeentries';
final public const RELATION_GROUP = 'theme_group';
final public const RELATION_GROUP = 'group';
final public const RELATION_IMAGES = 'anime.images';
final public const RELATION_SONG = 'song';
final public const RELATION_SYNONYMS = 'anime.animesynonyms';
Expand All @@ -75,7 +73,6 @@ class AnimeTheme extends BaseModel
protected $fillable = [
AnimeTheme::ATTRIBUTE_ANIME,
AnimeTheme::ATTRIBUTE_GROUP,
AnimeTheme::ATTRIBUTE_THEME_GROUP,
AnimeTheme::ATTRIBUTE_SEQUENCE,
AnimeTheme::ATTRIBUTE_SLUG,
AnimeTheme::ATTRIBUTE_SONG,
Expand Down Expand Up @@ -176,9 +173,9 @@ public function anime(): BelongsTo
*
* @return BelongsTo
*/
public function theme_group(): BelongsTo
public function group(): BelongsTo
{
return $this->belongsTo(Group::class, AnimeTheme::ATTRIBUTE_THEME_GROUP);
return $this->belongsTo(Group::class, AnimeTheme::ATTRIBUTE_GROUP);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Wiki/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Artist extends BaseModel
final public const RELATION_MEMBERS = 'members';
final public const RELATION_RESOURCES = 'resources';
final public const RELATION_SONGS = 'songs';
final public const RELATION_THEME_GROUPS = 'songs.animethemes.theme_group';
final public const RELATION_THEME_GROUPS = 'songs.animethemes.group';

/**
* The attributes that are mass assignable.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Wiki/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ public function getName(): string
*/
public function animethemes(): HasMany
{
return $this->hasMany(AnimeTheme::class, AnimeTheme::ATTRIBUTE_THEME_GROUP);
return $this->hasMany(AnimeTheme::class, AnimeTheme::ATTRIBUTE_GROUP);
}
}
1 change: 1 addition & 0 deletions app/Models/Wiki/Song.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Song extends BaseModel
final public const RELATION_ANIMETHEMES = 'animethemes';
final public const RELATION_ARTISTS = 'artists';
final public const RELATION_RESOURCES = 'resources';
final public const RELATION_THEME_GROUPS = 'animethemes.group';
final public const RELATION_VIDEOS = 'animethemes.animethemeentries.videos';

/**
Expand Down
1 change: 1 addition & 0 deletions app/Models/Wiki/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Video extends BaseModel implements Streamable, Viewable
final public const RELATION_ANIMESYNONYMS = 'animethemeentries.animetheme.anime.animesynonyms';
final public const RELATION_ANIMETHEME = 'animethemeentries.animetheme';
final public const RELATION_ANIMETHEMEENTRIES = 'animethemeentries';
final public const RELATION_GROUP = 'animethemeentries.animetheme.group';
final public const RELATION_AUDIO = 'audio';
final public const RELATION_SCRIPT = 'videoscript';
final public const RELATION_SONG = 'animethemeentries.animetheme.song';
Expand Down
11 changes: 0 additions & 11 deletions app/Nova/Resources/Wiki/Anime/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,6 @@ public function fields(NovaRequest $request): array
->filterable()
->showWhenPeeking(),

Text::make(__('nova.fields.anime_theme.group.name'), AnimeTheme::ATTRIBUTE_GROUP)
->sortable()
->nullable()
->rules(['nullable', 'max:192'])
->help(__('nova.fields.anime_theme.group.help'))
->showOnPreview()
->filterable()
->maxlength(192)
->enforceMaxlength()
->showWhenPeeking(),

Text::make(__('nova.fields.anime_theme.slug.name'), AnimeTheme::ATTRIBUTE_SLUG)
->sortable()
->rules(['required', 'max:192', 'alpha_dash'])
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\Scout\Elasticsearch\Api\Schema\Schema;

/**
* Class ThemeGroupField.
* Class ThemeSlugField.
*/
class ThemeSlugField extends StringField
{
Expand Down
2 changes: 0 additions & 2 deletions app/Scout/Elasticsearch/Api/Schema/Wiki/Anime/ThemeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use App\Models\Wiki\Anime\AnimeTheme;
use App\Scout\Elasticsearch\Api\Field\Base\IdField;
use App\Scout\Elasticsearch\Api\Field\Field;
use App\Scout\Elasticsearch\Api\Field\Wiki\Anime\Theme\ThemeGroupField;
use App\Scout\Elasticsearch\Api\Field\Wiki\Anime\Theme\ThemeSequenceField;
use App\Scout\Elasticsearch\Api\Field\Wiki\Anime\Theme\ThemeSlugField;
use App\Scout\Elasticsearch\Api\Field\Wiki\Anime\Theme\ThemeTypeField;
Expand Down Expand Up @@ -85,7 +84,6 @@ public function fields(): array
parent::fields(),
[
new IdField($this, AnimeTheme::ATTRIBUTE_ID),
new ThemeGroupField($this),
new ThemeSequenceField($this),
new ThemeSlugField($this),
new ThemeTypeField($this),
Expand Down
2 changes: 2 additions & 0 deletions app/Scout/Elasticsearch/Api/Schema/Wiki/AnimeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Wiki\AudioSchema;
use App\Http\Api\Schema\Wiki\ExternalResourceSchema;
use App\Http\Api\Schema\Wiki\GroupSchema;
use App\Http\Api\Schema\Wiki\ImageSchema;
use App\Http\Api\Schema\Wiki\Video\ScriptSchema;
use App\Http\Resources\Wiki\Resource\AnimeResource;
Expand Down Expand Up @@ -63,6 +64,7 @@ public function allowedIncludes(): array
new AllowedInclude(new AudioSchema(), Anime::RELATION_AUDIO),
new AllowedInclude(new EntrySchema(), Anime::RELATION_ENTRIES),
new AllowedInclude(new ExternalResourceSchema(), Anime::RELATION_RESOURCES),
new AllowedInclude(new GroupSchema(), Anime::RELATION_GROUPS),
new AllowedInclude(new ImageSchema(), Anime::RELATION_IMAGES),
new AllowedInclude(new ScriptSchema(), Anime::RELATION_SCRIPTS),
new AllowedInclude(new SeriesSchema(), Anime::RELATION_SERIES),
Expand Down
2 changes: 2 additions & 0 deletions app/Scout/Elasticsearch/Api/Schema/Wiki/ArtistSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Wiki\ExternalResourceSchema;
use App\Http\Api\Schema\Wiki\GroupSchema;
use App\Http\Api\Schema\Wiki\ImageSchema;
use App\Http\Resources\Wiki\Resource\ArtistResource;
use App\Models\Wiki\Artist;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function allowedIncludes(): array
new AllowedInclude(new ArtistSchema(), Artist::RELATION_GROUPS),
new AllowedInclude(new ArtistSchema(), Artist::RELATION_MEMBERS),
new AllowedInclude(new ExternalResourceSchema(), Artist::RELATION_RESOURCES),
new AllowedInclude(new GroupSchema(), Artist::RELATION_THEME_GROUPS),
new AllowedInclude(new ImageSchema(), Artist::RELATION_IMAGES),
new AllowedInclude(new SongSchema(), Artist::RELATION_SONGS),
new AllowedInclude(new ThemeSchema(), Artist::RELATION_ANIMETHEMES),
Expand Down
2 changes: 2 additions & 0 deletions app/Scout/Elasticsearch/Api/Schema/Wiki/SongSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Scout\Elasticsearch\Api\Schema\Wiki;

use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Wiki\GroupSchema;
use App\Http\Resources\Wiki\Resource\SongResource;
use App\Models\Wiki\Song;
use App\Scout\Elasticsearch\Api\Field\Base\IdField;
Expand Down Expand Up @@ -50,6 +51,7 @@ public function allowedIncludes(): array
return [
new AllowedInclude(new AnimeSchema(), Song::RELATION_ANIME),
new AllowedInclude(new ArtistSchema(), Song::RELATION_ARTISTS),
new AllowedInclude(new GroupSchema(), Song::RELATION_THEME_GROUPS),
new AllowedInclude(new ThemeSchema(), Song::RELATION_ANIMETHEMES),
];
}
Expand Down
2 changes: 2 additions & 0 deletions app/Scout/Elasticsearch/Api/Schema/Wiki/VideoSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Http\Api\Include\AllowedInclude;
use App\Http\Api\Schema\Wiki\AudioSchema;
use App\Http\Api\Schema\Wiki\GroupSchema;
use App\Http\Resources\Wiki\Resource\VideoResource;
use App\Models\Wiki\Video;
use App\Scout\Elasticsearch\Api\Field\Base\IdField;
Expand Down Expand Up @@ -64,6 +65,7 @@ public function allowedIncludes(): array
new AllowedInclude(new AnimeSchema(), Video::RELATION_ANIME),
new AllowedInclude(new AudioSchema(), Video::RELATION_AUDIO),
new AllowedInclude(new EntrySchema(), Video::RELATION_ANIMETHEMEENTRIES),
new AllowedInclude(new GroupSchema(), Video::RELATION_GROUP),
new AllowedInclude(new ThemeSchema(), Video::RELATION_ANIMETHEME),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function up(): void
$table->id(AnimeTheme::ATTRIBUTE_ID);
$table->timestamps(6);
$table->softDeletes(BaseModel::ATTRIBUTE_DELETED_AT, 6);
$table->string(AnimeTheme::ATTRIBUTE_GROUP)->nullable();
$table->integer(AnimeTheme::ATTRIBUTE_TYPE)->nullable();
$table->integer(AnimeTheme::ATTRIBUTE_SEQUENCE)->nullable();
$table->string(AnimeTheme::ATTRIBUTE_SLUG);
Expand Down
Loading

0 comments on commit 1744b54

Please sign in to comment.