mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
97 lines
2.8 KiB
PHP
97 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Pivots\Wiki;
|
|
|
|
use App\Events\Pivot\Wiki\ArtistMember\ArtistMemberCreated;
|
|
use App\Events\Pivot\Wiki\ArtistMember\ArtistMemberDeleted;
|
|
use App\Events\Pivot\Wiki\ArtistMember\ArtistMemberUpdated;
|
|
use App\Models\Wiki\Artist;
|
|
use App\Pivots\BasePivot;
|
|
use Database\Factories\Pivots\Wiki\ArtistMemberFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use OwenIt\Auditing\Auditable as HasAudits;
|
|
use OwenIt\Auditing\Contracts\Auditable;
|
|
|
|
/**
|
|
* @property Artist $artist
|
|
* @property int $artist_id
|
|
* @property string|null $alias
|
|
* @property string|null $as
|
|
* @property Artist $member
|
|
* @property int $member_id
|
|
* @property string|null $notes
|
|
* @property int $relevance
|
|
*
|
|
* @method static ArtistMemberFactory factory(...$parameters)
|
|
*/
|
|
#[Table(ArtistMember::TABLE)]
|
|
class ArtistMember extends BasePivot implements Auditable
|
|
{
|
|
use HasAudits;
|
|
|
|
final public const string TABLE = 'artist_member';
|
|
|
|
final public const string ATTRIBUTE_ALIAS = 'alias';
|
|
final public const string ATTRIBUTE_AS = 'as';
|
|
final public const string ATTRIBUTE_ARTIST = 'artist_id';
|
|
final public const string ATTRIBUTE_MEMBER = 'member_id';
|
|
final public const string ATTRIBUTE_NOTES = 'notes';
|
|
final public const string ATTRIBUTE_RELEVANCE = 'relevance';
|
|
|
|
final public const string RELATION_ARTIST = 'artist';
|
|
final public const string RELATION_MEMBER = 'member';
|
|
|
|
/**
|
|
* The event map for the model.
|
|
*
|
|
* Allows for object-based events for native Eloquent events.
|
|
*
|
|
* @var array<string, class-string>
|
|
*/
|
|
protected $dispatchesEvents = [
|
|
'created' => ArtistMemberCreated::class,
|
|
'deleted' => ArtistMemberDeleted::class,
|
|
'updated' => ArtistMemberUpdated::class,
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
ArtistMember::ATTRIBUTE_ALIAS => 'string',
|
|
ArtistMember::ATTRIBUTE_ARTIST => 'int',
|
|
ArtistMember::ATTRIBUTE_AS => 'string',
|
|
ArtistMember::ATTRIBUTE_MEMBER => 'int',
|
|
ArtistMember::ATTRIBUTE_NOTES => 'string',
|
|
ArtistMember::ATTRIBUTE_RELEVANCE => 'int',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Gets the artist that owns the artist member.
|
|
*
|
|
* @return BelongsTo<Artist, $this>
|
|
*/
|
|
public function artist(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Artist::class, ArtistMember::ATTRIBUTE_ARTIST);
|
|
}
|
|
|
|
/**
|
|
* Gets the member that owns the artist member.
|
|
*
|
|
* @return BelongsTo<Artist, $this>
|
|
*/
|
|
public function member(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Artist::class, ArtistMember::ATTRIBUTE_MEMBER);
|
|
}
|
|
}
|