mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
feat: add IDs for pivots (#1149)
This commit is contained in:
@@ -24,6 +24,7 @@ yarn-error.log
|
||||
auth.json
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
*.sql
|
||||
public/css/app.css
|
||||
public/js/app.js
|
||||
test.php
|
||||
@@ -199,7 +199,7 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
|
||||
return $this->morphToMany(Image::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGEABLE_ID, Imageable::ATTRIBUTE_IMAGE)
|
||||
->using(Imageable::class)
|
||||
->as('playlistimage')
|
||||
->withPivot(Imageable::ATTRIBUTE_DEPTH)
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
|
||||
return $this->belongsToMany(Series::class, AnimeSeries::TABLE, AnimeSeries::ATTRIBUTE_ANIME, AnimeSeries::ATTRIBUTE_SERIES)
|
||||
->using(AnimeSeries::class)
|
||||
->as(AnimeSeriesJsonResource::$wrap)
|
||||
->withPivot(AnimeSeries::ATTRIBUTE_ID)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -242,8 +243,8 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
|
||||
{
|
||||
return $this->morphToMany(ExternalResource::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID, Resourceable::ATTRIBUTE_RESOURCE)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('animeresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -255,7 +256,7 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
|
||||
return $this->morphToMany(Image::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGEABLE_ID, Imageable::ATTRIBUTE_IMAGE)
|
||||
->using(Imageable::class)
|
||||
->as('animeimage')
|
||||
->withPivot(Imageable::ATTRIBUTE_DEPTH)
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -267,6 +268,7 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
|
||||
return $this->belongsToMany(Studio::class, AnimeStudio::TABLE, AnimeStudio::ATTRIBUTE_ANIME, AnimeStudio::ATTRIBUTE_STUDIO)
|
||||
->using(AnimeStudio::class)
|
||||
->as(AnimeStudioJsonResource::$wrap)
|
||||
->withPivot(AnimeStudio::ATTRIBUTE_ID)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
|
||||
)
|
||||
->using(AnimeThemeEntryVideo::class)
|
||||
->as(AnimeThemeEntryVideoJsonResource::$wrap)
|
||||
->withPivot([AnimeThemeEntryVideo::ATTRIBUTE_ID])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -218,8 +219,8 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
|
||||
{
|
||||
return $this->morphToMany(ExternalResource::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID, Resourceable::ATTRIBUTE_RESOURCE)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('entryresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
|
||||
->using(ArtistSong::class)
|
||||
->withPivot([ArtistSong::ATTRIBUTE_ALIAS, ArtistSong::ATTRIBUTE_AS])
|
||||
->as(ArtistSongJsonResource::$wrap)
|
||||
->withPivot(ArtistSong::ATTRIBUTE_ID)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -254,8 +255,14 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
|
||||
{
|
||||
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, ArtistMember::ATTRIBUTE_RELEVANCE])
|
||||
->as(ArtistMemberJsonResource::$wrap)
|
||||
->withPivot([
|
||||
ArtistMember::ATTRIBUTE_ID,
|
||||
ArtistMember::ATTRIBUTE_ALIAS,
|
||||
ArtistMember::ATTRIBUTE_AS,
|
||||
ArtistMember::ATTRIBUTE_NOTES,
|
||||
ArtistMember::ATTRIBUTE_RELEVANCE,
|
||||
])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -266,8 +273,14 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
|
||||
{
|
||||
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(ArtistMemberJsonResource::$wrap)
|
||||
->withPivot([
|
||||
ArtistMember::ATTRIBUTE_ID,
|
||||
ArtistMember::ATTRIBUTE_ALIAS,
|
||||
ArtistMember::ATTRIBUTE_AS,
|
||||
ArtistMember::ATTRIBUTE_NOTES,
|
||||
ArtistMember::ATTRIBUTE_RELEVANCE,
|
||||
])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -278,8 +291,8 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
|
||||
{
|
||||
return $this->morphToMany(ExternalResource::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID, Resourceable::ATTRIBUTE_RESOURCE)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('artistresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -290,8 +303,8 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
|
||||
{
|
||||
return $this->morphToMany(Image::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGEABLE_ID, Imageable::ATTRIBUTE_IMAGE)
|
||||
->using(Imageable::class)
|
||||
->withPivot(Imageable::ATTRIBUTE_DEPTH)
|
||||
->as('artistimage')
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
|
||||
{
|
||||
return $this->morphedByMany(Anime::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('animeresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
|
||||
{
|
||||
return $this->morphedByMany(AnimeThemeEntry::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('entryresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
|
||||
{
|
||||
return $this->morphedByMany(Artist::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('artistresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
|
||||
{
|
||||
return $this->morphedByMany(Song::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('songresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
|
||||
{
|
||||
return $this->morphedByMany(Studio::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('studioresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ class Image extends BaseModel implements Auditable, SoftDeletable
|
||||
return $this->morphedByMany(Anime::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGE, Imageable::ATTRIBUTE_IMAGEABLE_ID)
|
||||
->using(Imageable::class)
|
||||
->as('animeimage')
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ class Image extends BaseModel implements Auditable, SoftDeletable
|
||||
return $this->morphedByMany(Artist::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGE, Imageable::ATTRIBUTE_IMAGEABLE_ID)
|
||||
->using(Imageable::class)
|
||||
->as('artistimage')
|
||||
->withPivot(Imageable::ATTRIBUTE_DEPTH)
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -156,6 +157,7 @@ class Image extends BaseModel implements Auditable, SoftDeletable
|
||||
return $this->morphedByMany(Studio::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGE, Imageable::ATTRIBUTE_IMAGEABLE_ID)
|
||||
->using(Imageable::class)
|
||||
->as('studioimage')
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -167,6 +169,7 @@ class Image extends BaseModel implements Auditable, SoftDeletable
|
||||
return $this->morphedByMany(Playlist::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGE, Imageable::ATTRIBUTE_IMAGEABLE_ID)
|
||||
->using(Imageable::class)
|
||||
->as('playlistimage')
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ class Series extends BaseModel implements Auditable, SoftDeletable
|
||||
return $this->belongsToMany(Anime::class, AnimeSeries::TABLE, AnimeSeries::ATTRIBUTE_SERIES, AnimeSeries::ATTRIBUTE_ANIME)
|
||||
->using(AnimeSeries::class)
|
||||
->as(AnimeSeriesJsonResource::$wrap)
|
||||
->withPivot([AnimeSeries::ATTRIBUTE_ID])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
|
||||
{
|
||||
return $this->belongsToMany(Artist::class, ArtistSong::TABLE, ArtistSong::ATTRIBUTE_SONG, ArtistSong::ATTRIBUTE_ARTIST)
|
||||
->using(ArtistSong::class)
|
||||
->withPivot([ArtistSong::ATTRIBUTE_ALIAS, ArtistSong::ATTRIBUTE_AS])
|
||||
->as(ArtistSongJsonResource::$wrap)
|
||||
->withPivot([ArtistSong::ATTRIBUTE_ID, ArtistSong::ATTRIBUTE_ALIAS, ArtistSong::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
|
||||
{
|
||||
return $this->morphToMany(ExternalResource::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID, Resourceable::ATTRIBUTE_RESOURCE)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('songresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
|
||||
return $this->belongsToMany(Anime::class, AnimeStudio::TABLE, AnimeStudio::ATTRIBUTE_STUDIO, AnimeStudio::ATTRIBUTE_ANIME)
|
||||
->using(AnimeStudio::class)
|
||||
->as(AnimeStudioJsonResource::$wrap)
|
||||
->withPivot([AnimeStudio::ATTRIBUTE_ID])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -148,8 +149,8 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
|
||||
{
|
||||
return $this->morphToMany(ExternalResource::class, Resourceable::RELATION_RESOURCEABLE, Resourceable::TABLE, Resourceable::ATTRIBUTE_RESOURCEABLE_ID, Resourceable::ATTRIBUTE_RESOURCE)
|
||||
->using(Resourceable::class)
|
||||
->withPivot(Resourceable::ATTRIBUTE_AS)
|
||||
->as('studioresource')
|
||||
->withPivot([Resourceable::ATTRIBUTE_ID, Resourceable::ATTRIBUTE_AS])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
|
||||
return $this->morphToMany(Image::class, Imageable::RELATION_IMAGEABLE, Imageable::TABLE, Imageable::ATTRIBUTE_IMAGEABLE_ID, Imageable::ATTRIBUTE_IMAGE)
|
||||
->using(Imageable::class)
|
||||
->as('studioimage')
|
||||
->withPivot(Imageable::ATTRIBUTE_DEPTH)
|
||||
->withPivot([Imageable::ATTRIBUTE_ID, Imageable::ATTRIBUTE_DEPTH])
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +310,7 @@ class Video extends BaseModel implements Auditable, SoftDeletable, Streamable
|
||||
return $this->belongsToMany(AnimeThemeEntry::class, AnimeThemeEntryVideo::TABLE, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)
|
||||
->using(AnimeThemeEntryVideo::class)
|
||||
->as(AnimeThemeEntryVideoJsonResource::$wrap)
|
||||
->withPivot([AnimeThemeEntryVideo::ATTRIBUTE_ID])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Pivots;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphPivot;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
@@ -18,32 +18,19 @@ abstract class BaseMorphPivot extends MorphPivot
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
final public const ATTRIBUTE_ID = 'id';
|
||||
final public const ATTRIBUTE_CREATED_AT = Model::CREATED_AT;
|
||||
final public const ATTRIBUTE_UPDATED_AT = Model::UPDATED_AT;
|
||||
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $incrementing = true;
|
||||
|
||||
/**
|
||||
* The storage format of the model's date columns.
|
||||
*/
|
||||
protected $dateFormat = 'Y-m-d\TH:i:s.u';
|
||||
|
||||
/**
|
||||
* Set the keys for a select query.
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
protected function setKeysForSelectQuery($query): Builder
|
||||
{
|
||||
foreach ($this->getPrimaryKeys() as $primaryKey) {
|
||||
$query->where($primaryKey, $this->getAttribute($primaryKey));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract protected function getPrimaryKeys(): array;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Pivots;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
@@ -18,32 +18,19 @@ abstract class BasePivot extends Pivot
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
final public const ATTRIBUTE_ID = 'id';
|
||||
final public const ATTRIBUTE_CREATED_AT = Model::CREATED_AT;
|
||||
final public const ATTRIBUTE_UPDATED_AT = Model::UPDATED_AT;
|
||||
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $incrementing = true;
|
||||
|
||||
/**
|
||||
* The storage format of the model's date columns.
|
||||
*/
|
||||
protected $dateFormat = 'Y-m-d\TH:i:s.u';
|
||||
|
||||
/**
|
||||
* Set the keys for a select query.
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
protected function setKeysForSelectQuery($query): Builder
|
||||
{
|
||||
foreach ($this->getPrimaryKeys() as $primaryKey) {
|
||||
$query->where($primaryKey, $this->getAttribute($primaryKey));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract protected function getPrimaryKeys(): array;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property Page $page
|
||||
* @property int $page_id
|
||||
* @property Role $role
|
||||
@@ -27,7 +26,6 @@ class PageRole extends BasePivot
|
||||
{
|
||||
final public const string TABLE = 'page_roles';
|
||||
|
||||
final public const string ATTRIBUTE_ID = 'id';
|
||||
final public const string ATTRIBUTE_PAGE = 'page_id';
|
||||
final public const string ATTRIBUTE_ROLE = 'role_id';
|
||||
final public const string ATTRIBUTE_TYPE = 'type';
|
||||
@@ -46,18 +44,6 @@ class PageRole extends BasePivot
|
||||
PageRole::ATTRIBUTE_TYPE,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
PageRole::ATTRIBUTE_ID,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -96,20 +96,6 @@ class Imageable extends BaseMorphPivot
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
Imageable::ATTRIBUTE_IMAGE,
|
||||
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
|
||||
Imageable::ATTRIBUTE_IMAGEABLE_ID,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image that owns the imageable.
|
||||
*
|
||||
|
||||
@@ -83,20 +83,6 @@ class Resourceable extends BaseMorphPivot
|
||||
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
Resourceable::ATTRIBUTE_RESOURCE,
|
||||
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
|
||||
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -54,19 +54,6 @@ class AnimeSeries extends BasePivot
|
||||
AnimeSeries::ATTRIBUTE_SERIES,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
AnimeSeries::ATTRIBUTE_ANIME,
|
||||
AnimeSeries::ATTRIBUTE_SERIES,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -54,19 +54,6 @@ class AnimeStudio extends BasePivot
|
||||
AnimeStudio::ATTRIBUTE_STUDIO,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
AnimeStudio::ATTRIBUTE_ANIME,
|
||||
AnimeStudio::ATTRIBUTE_STUDIO,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -58,19 +58,6 @@ class AnimeThemeEntryVideo extends BasePivot
|
||||
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
AnimeThemeEntryVideo::ATTRIBUTE_ENTRY,
|
||||
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -67,19 +67,6 @@ class ArtistMember extends BasePivot
|
||||
ArtistMember::ATTRIBUTE_RELEVANCE,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
ArtistMember::ATTRIBUTE_ARTIST,
|
||||
ArtistMember::ATTRIBUTE_MEMBER,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -46,19 +46,6 @@ class ArtistSong extends BasePivot
|
||||
ArtistSong::ATTRIBUTE_SONG,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPrimaryKeys(): array
|
||||
{
|
||||
return [
|
||||
ArtistSong::ATTRIBUTE_ARTIST,
|
||||
ArtistSong::ATTRIBUTE_SONG,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -15,12 +15,13 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('anime_series')) {
|
||||
Schema::create('anime_series', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps(6);
|
||||
$table->unsignedBigInteger('anime_id');
|
||||
$table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('series_id');
|
||||
$table->foreign('series_id')->references('series_id')->on('series')->cascadeOnDelete();
|
||||
$table->primary(['anime_id', 'series_id']);
|
||||
$table->unique(['anime_id', 'series_id'], 'anime_series_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,13 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('anime_theme_entry_video')) {
|
||||
Schema::create('anime_theme_entry_video', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps(6);
|
||||
$table->unsignedBigInteger('entry_id');
|
||||
$table->foreign('entry_id')->references('entry_id')->on('anime_theme_entries')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('video_id');
|
||||
$table->foreign('video_id')->references('video_id')->on('videos')->cascadeOnDelete();
|
||||
$table->primary(['entry_id', 'video_id']);
|
||||
$table->unique(['entry_id', 'video_id'], 'entry_video_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,15 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('artist_song')) {
|
||||
Schema::create('artist_song', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps(6);
|
||||
$table->unsignedBigInteger('artist_id');
|
||||
$table->foreign('artist_id')->references('artist_id')->on('artists')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('song_id');
|
||||
$table->foreign('song_id')->references('song_id')->on('songs')->cascadeOnDelete();
|
||||
$table->primary(['artist_id', 'song_id']);
|
||||
$table->string('as')->nullable();
|
||||
$table->string('alias')->nullable();
|
||||
$table->unique(['artist_id', 'song_id'], 'artist_song_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,16 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('artist_member')) {
|
||||
Schema::create('artist_member', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps(6);
|
||||
$table->unsignedBigInteger('artist_id');
|
||||
$table->foreign('artist_id')->references('artist_id')->on('artists')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('member_id');
|
||||
$table->foreign('member_id')->references('artist_id')->on('artists')->cascadeOnDelete();
|
||||
$table->primary(['artist_id', 'member_id']);
|
||||
$table->string('as')->nullable();
|
||||
$table->string('alias')->nullable();
|
||||
$table->string('notes')->nullable();
|
||||
$table->unique(['artist_id', 'member_id'], 'artist_member_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,13 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('anime_studio')) {
|
||||
Schema::create('anime_studio', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps(6);
|
||||
$table->unsignedBigInteger('anime_id');
|
||||
$table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('studio_id');
|
||||
$table->foreign('studio_id')->references('studio_id')->on('studios')->cascadeOnDelete();
|
||||
$table->primary(['anime_id', 'studio_id']);
|
||||
$table->unique(['anime_id', 'studio_id'], 'anime_studio_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('resourceables')) {
|
||||
Schema::create('resourceables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('resource_id');
|
||||
$table->foreign('resource_id')->references('resource_id')->on('resources')->cascadeOnDelete();
|
||||
|
||||
@@ -23,11 +24,11 @@ return new class extends Migration
|
||||
|
||||
$table->timestamps(6);
|
||||
|
||||
$table->primary([
|
||||
$table->unique([
|
||||
'resource_id',
|
||||
'resourceable_type',
|
||||
'resourceable_id',
|
||||
]);
|
||||
], 'resourceable_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasTable('imageables')) {
|
||||
Schema::create('imageables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('image_id');
|
||||
$table->foreign('image_id')->references('image_id')->on('images')->cascadeOnDelete();
|
||||
|
||||
@@ -23,11 +24,11 @@ return new class extends Migration
|
||||
|
||||
$table->timestamps(6);
|
||||
|
||||
$table->primary([
|
||||
$table->unique([
|
||||
'image_id',
|
||||
'imageable_type',
|
||||
'imageable_id',
|
||||
]);
|
||||
], 'imageable_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user