mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
chore!: database & GraphQL changes (#1070)
This commit is contained in:
@@ -21,7 +21,7 @@ trait SoftDeletes
|
||||
|
||||
public const ATTRIBUTE_DELETED_AT = ModelConstants::ATTRIBUTE_DELETED_AT;
|
||||
|
||||
public function restore(): ?bool
|
||||
public function restore(): bool
|
||||
{
|
||||
// If the restoring event does not return false, we will proceed with this
|
||||
// restore operation. Otherwise, we bail out so the developer will stop
|
||||
|
||||
@@ -11,11 +11,10 @@ enum AnimeMediaFormat: int implements HasLabel
|
||||
{
|
||||
use LocalizesName;
|
||||
|
||||
case UNKNOWN = 0;
|
||||
case TV = 1;
|
||||
case TV_SHORT = 2;
|
||||
case OVA = 3;
|
||||
case MOVIE = 4;
|
||||
case SPECIAL = 5;
|
||||
case ONA = 6;
|
||||
case TV = 0;
|
||||
case TV_SHORT = 1;
|
||||
case OVA = 2;
|
||||
case MOVIE = 3;
|
||||
case SPECIAL = 4;
|
||||
case ONA = 5;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ enum VideoSource: int implements HasLabel
|
||||
|
||||
/**
|
||||
* Score sources to help prioritize videos.
|
||||
* Note: This should be refactored into attributes.
|
||||
* TODO: This should be refactored into attributes.
|
||||
*/
|
||||
public function getPriority(): int
|
||||
{
|
||||
|
||||
@@ -41,13 +41,13 @@ class ArtistDeleted extends WikiDeletedEvent implements CascadesDeletesEvent
|
||||
|
||||
$this->getModel()->performances->each(fn (Performance $performance) => $performance->delete());
|
||||
|
||||
$this->getModel()->memberships->each(function (Membership $membership) {
|
||||
$this->getModel()->memberships->each(function (Membership $membership): void {
|
||||
$membership->performances->each(fn (Performance $performance) => $performance->delete());
|
||||
|
||||
$membership->delete();
|
||||
});
|
||||
|
||||
$this->getModel()->groupships->each(function (Membership $membership) {
|
||||
$this->getModel()->groupships->each(function (Membership $membership): void {
|
||||
$membership->performances->each(fn (Performance $performance) => $performance->delete());
|
||||
|
||||
$membership->delete();
|
||||
|
||||
@@ -41,13 +41,13 @@ class ArtistForceDeleted extends WikiDeletedEvent implements CascadesDeletesEven
|
||||
|
||||
$this->getModel()->performances->each(fn (Performance $performance) => $performance->forceDelete());
|
||||
|
||||
$this->getModel()->memberships->each(function (Membership $membership) {
|
||||
$this->getModel()->memberships->each(function (Membership $membership): void {
|
||||
$membership->performances->each(fn (Performance $performance) => $performance->forceDelete());
|
||||
|
||||
$membership->forceDelete();
|
||||
});
|
||||
|
||||
$this->getModel()->groupships->each(function (Membership $membership) {
|
||||
$this->getModel()->groupships->each(function (Membership $membership): void {
|
||||
$membership->performances->each(fn (Performance $performance) => $performance->forceDelete());
|
||||
|
||||
$membership->forceDelete();
|
||||
|
||||
@@ -33,17 +33,17 @@ class ArtistRestored extends WikiRestoredEvent implements CascadesRestoresEvent
|
||||
->performances()
|
||||
->withoutGlobalScope(SoftDeletingScope::class)
|
||||
->get()
|
||||
->each(fn (Performance $performance) => $performance->restore());
|
||||
->each(fn (Performance $performance): bool => $performance->restore());
|
||||
|
||||
$this->getModel()
|
||||
->memberships()
|
||||
->withoutGlobalScope(SoftDeletingScope::class)
|
||||
->get()
|
||||
->each(function (Membership $membership) {
|
||||
->each(function (Membership $membership): void {
|
||||
$membership->performances()
|
||||
->withoutGlobalScope(SoftDeletingScope::class)
|
||||
->get()
|
||||
->each(fn (Performance $performance) => $performance->restore());
|
||||
->each(fn (Performance $performance): bool => $performance->restore());
|
||||
|
||||
$membership->restore();
|
||||
});
|
||||
@@ -52,11 +52,11 @@ class ArtistRestored extends WikiRestoredEvent implements CascadesRestoresEvent
|
||||
->groupships()
|
||||
->withoutGlobalScope(SoftDeletingScope::class)
|
||||
->get()
|
||||
->each(function (Membership $membership) {
|
||||
->each(function (Membership $membership): void {
|
||||
$membership->performances()
|
||||
->withoutGlobalScope(SoftDeletingScope::class)
|
||||
->get()
|
||||
->each(fn (Performance $performance) => $performance->restore());
|
||||
->each(fn (Performance $performance): bool => $performance->restore());
|
||||
|
||||
$membership->restore();
|
||||
});
|
||||
|
||||
@@ -10,7 +10,6 @@ use App\Contracts\GraphQL\Fields\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\GraphQL\Schema\Fields\DateTimeTzField;
|
||||
use App\Models\Admin\FeaturedTheme;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FeaturedThemeEndAtField extends DateTimeTzField implements CreatableField, RequiredOnCreation, UpdatableField
|
||||
|
||||
@@ -10,7 +10,6 @@ use App\Contracts\GraphQL\Fields\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\GraphQL\Schema\Fields\DateTimeTzField;
|
||||
use App\Models\Admin\FeaturedTheme;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FeaturedThemeStartAtField extends DateTimeTzField implements CreatableField, RequiredOnCreation, UpdatableField
|
||||
|
||||
@@ -11,7 +11,7 @@ class RolePriorityField extends IntField
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Role::ATTRIBUTE_PRIORITY);
|
||||
parent::__construct(Role::ATTRIBUTE_PRIORITY, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -13,7 +13,7 @@ class ImageableDepthField extends IntField implements CreatableField, UpdatableF
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Imageable::ATTRIBUTE_DEPTH);
|
||||
parent::__construct(Imageable::ATTRIBUTE_DEPTH, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -13,7 +13,7 @@ class ArtistMemberRelevanceField extends IntField implements CreatableField, Upd
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(ArtistMember::ATTRIBUTE_RELEVANCE);
|
||||
parent::__construct(ArtistMember::ATTRIBUTE_RELEVANCE, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -16,7 +16,7 @@ class AnimeSynonymTypeField extends EnumField implements CreatableField, Require
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(AnimeSynonym::ATTRIBUTE_TYPE, AnimeSynonymType::class);
|
||||
parent::__construct(AnimeSynonym::ATTRIBUTE_TYPE, AnimeSynonymType::class, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -13,7 +13,7 @@ class AnimeThemeEntryVersionField extends IntField implements CreatableField, Up
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_VERSION);
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_VERSION, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -13,7 +13,7 @@ class PerformanceRelevanceField extends IntField implements CreatableField, Upda
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Performance::ATTRIBUTE_RELEVANCE);
|
||||
parent::__construct(Performance::ATTRIBUTE_RELEVANCE, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -11,7 +11,7 @@ class VideoMimetypeField extends StringField
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Video::ATTRIBUTE_MIMETYPE);
|
||||
parent::__construct(Video::ATTRIBUTE_MIMETYPE, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -16,7 +16,7 @@ class VideoOverlapField extends EnumField implements CreatableField, RequiredOnC
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Video::ATTRIBUTE_OVERLAP, VideoOverlap::class);
|
||||
parent::__construct(Video::ATTRIBUTE_OVERLAP, VideoOverlap::class, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -11,7 +11,7 @@ class VideoSizeField extends IntField
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Video::ATTRIBUTE_SIZE);
|
||||
parent::__construct(Video::ATTRIBUTE_SIZE, nullable: false);
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
|
||||
@@ -33,10 +33,8 @@ class FeaturedThemeType extends EloquentType
|
||||
public function relations(): array
|
||||
{
|
||||
return [
|
||||
new BelongsToRelation(new AnimeThemeEntryType(), FeaturedTheme::RELATION_ENTRY)
|
||||
->notNullable(),
|
||||
new BelongsToRelation(new VideoType(), FeaturedTheme::RELATION_VIDEO)
|
||||
->notNullable(),
|
||||
new BelongsToRelation(new AnimeThemeEntryType(), FeaturedTheme::RELATION_ENTRY),
|
||||
new BelongsToRelation(new VideoType(), FeaturedTheme::RELATION_VIDEO),
|
||||
new BelongsToRelation(new UserType(), FeaturedTheme::RELATION_USER),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field\Admin\Announcement;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Query\Query;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Admin\Announcement;
|
||||
use App\Models\Admin\FeaturedTheme;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AnnouncementEndAtField extends DateField implements CreatableField, UpdatableField
|
||||
{
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct($schema, Announcement::ATTRIBUTE_END_AT);
|
||||
}
|
||||
|
||||
public function shouldRender(Query $query): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCreationRules(Request $request): array
|
||||
{
|
||||
$allowedDateFormats = array_column(AllowedDateFormat::cases(), 'value');
|
||||
|
||||
return [
|
||||
'required',
|
||||
'after:'.Announcement::ATTRIBUTE_START_AT,
|
||||
Str::of('date_format:')
|
||||
->append(implode(',', $allowedDateFormats))
|
||||
->__toString(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getUpdateRules(Request $request): array
|
||||
{
|
||||
$allowedDateFormats = array_column(AllowedDateFormat::cases(), 'value');
|
||||
|
||||
return [
|
||||
'sometimes',
|
||||
'required',
|
||||
'after:'.Announcement::ATTRIBUTE_START_AT,
|
||||
Str::of('date_format:')
|
||||
->append(implode(',', $allowedDateFormats))
|
||||
->__toString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field\Admin\Announcement;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Query\Query;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Admin\Announcement;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AnnouncementStartAtField extends DateField implements CreatableField, UpdatableField
|
||||
{
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct($schema, Announcement::ATTRIBUTE_START_AT);
|
||||
}
|
||||
|
||||
public function shouldRender(Query $query): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCreationRules(Request $request): array
|
||||
{
|
||||
$allowedDateFormats = array_column(AllowedDateFormat::cases(), 'value');
|
||||
|
||||
return [
|
||||
'required',
|
||||
'before:'.Announcement::ATTRIBUTE_END_AT,
|
||||
Str::of('date_format:')
|
||||
->append(implode(',', $allowedDateFormats))
|
||||
->__toString(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getUpdateRules(Request $request): array
|
||||
{
|
||||
$allowedDateFormats = array_column(AllowedDateFormat::cases(), 'value');
|
||||
|
||||
return [
|
||||
'sometimes',
|
||||
'required',
|
||||
'before:'.Announcement::ATTRIBUTE_END_AT,
|
||||
Str::of('date_format:')
|
||||
->append(implode(',', $allowedDateFormats))
|
||||
->__toString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Schema\Admin;
|
||||
|
||||
use App\Http\Api\Field\Admin\Announcement\AnnouncementContentField;
|
||||
use App\Http\Api\Field\Admin\Announcement\AnnouncementEndAtField;
|
||||
use App\Http\Api\Field\Admin\Announcement\AnnouncementStartAtField;
|
||||
use App\Http\Api\Field\Base\CreatedAtField;
|
||||
use App\Http\Api\Field\Base\IdField;
|
||||
use App\Http\Api\Field\Base\UpdatedAtField;
|
||||
@@ -38,6 +40,8 @@ class AnnouncementSchema extends EloquentSchema
|
||||
new CreatedAtField($this),
|
||||
new UpdatedAtField($this),
|
||||
new IdField($this, Announcement::ATTRIBUTE_ID),
|
||||
new AnnouncementStartAtField($this),
|
||||
new AnnouncementEndAtField($this),
|
||||
new AnnouncementContentField($this),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ use Throwable;
|
||||
* @property Carbon|null $finished_at
|
||||
* @property ActionLogStatus $status
|
||||
* @property Model $target
|
||||
* @property int $user_id
|
||||
* @property User $user
|
||||
* @property int|null $user_id
|
||||
* @property User|null $user
|
||||
*/
|
||||
#[ObservedBy(ActionLogObserver::class)]
|
||||
class ActionLog extends Model implements Nameable
|
||||
|
||||
@@ -20,8 +20,8 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
/**
|
||||
* @property int $announcement_id
|
||||
* @property string $content
|
||||
* @property Carbon|null $end_at
|
||||
* @property Carbon|null $start_at
|
||||
* @property Carbon $end_at
|
||||
* @property Carbon $start_at
|
||||
*
|
||||
* @method static AnnouncementFactory factory(...$parameters)
|
||||
* @method static Builder<Announcement> current()
|
||||
|
||||
@@ -21,11 +21,11 @@ use OwenIt\Auditing\Auditable as HasAudits;
|
||||
use OwenIt\Auditing\Contracts\Auditable;
|
||||
|
||||
/**
|
||||
* @property Carbon|null $end_at
|
||||
* @property Carbon $end_at
|
||||
* @property AnimeThemeEntry|null $animethemeentry
|
||||
* @property int $entry_id
|
||||
* @property int $feature_id
|
||||
* @property Carbon|null $start_at
|
||||
* @property Carbon $start_at
|
||||
* @property User|null $user
|
||||
* @property int|null $user_id
|
||||
* @property Video|null $video
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Carbon;
|
||||
use Spatie\Permission\Models\Role as BaseRole;
|
||||
|
||||
/**
|
||||
* @property string $color
|
||||
* @property string|null $color
|
||||
* @property bool $default
|
||||
* @property Carbon $created_at
|
||||
* @property string $guard_name
|
||||
@@ -35,6 +35,15 @@ class Role extends BaseRole implements Nameable
|
||||
final public const string RELATION_PERMISSIONS = 'permissions';
|
||||
final public const string RELATION_USERS = 'users';
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
Role::ATTRIBUTE_PRIORITY => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -46,7 +46,7 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
* @property DiscordThread|null $discordthread
|
||||
* @property Collection<int, ExternalEntry> $externalentries
|
||||
* @property Collection<int, Image> $images
|
||||
* @property AnimeMediaFormat $media_format
|
||||
* @property AnimeMediaFormat|null $media_format
|
||||
* @property string $name
|
||||
* @property Collection<int, ExternalResource> $resources
|
||||
* @property AnimeSeason|null $season
|
||||
|
||||
@@ -74,6 +74,15 @@ class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable
|
||||
AnimeSynonym::ATTRIBUTE_TYPE,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
AnimeSynonym::ATTRIBUTE_TYPE => AnimeSynonymType::OTHER->value,
|
||||
];
|
||||
|
||||
/**
|
||||
* The event map for the model.
|
||||
*
|
||||
|
||||
@@ -47,7 +47,7 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
* @property Song|null $song
|
||||
* @property int|null $song_id
|
||||
* @property int $theme_id
|
||||
* @property ThemeType|null $type
|
||||
* @property ThemeType $type
|
||||
*
|
||||
* @method static AnimeThemeFactory factory(...$parameters)
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ use Znck\Eloquent\Traits\BelongsToThrough as ZnckBelongsToThrough;
|
||||
* @property Collection<int, ExternalResource> $resources
|
||||
* @property bool $spoiler
|
||||
* @property int $theme_id
|
||||
* @property int|null $version
|
||||
* @property int $version
|
||||
* @property Collection<int, Video> $videos
|
||||
*
|
||||
* @method static AnimeThemeEntryFactory factory(...$parameters)
|
||||
@@ -137,6 +137,15 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
|
||||
AnimeThemeEntry::ATTRIBUTE_VERSION,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
AnimeThemeEntry::ATTRIBUTE_VERSION => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
@@ -176,7 +185,7 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
|
||||
$array['theme'] = $theme->toSearchableArray();
|
||||
|
||||
// Overwrite version with readable format "v{#}"
|
||||
$array['version'] = Str::of(blank($this->version) ? '1' : $this->version)->prepend('v')->__toString();
|
||||
$array['version'] = Str::of(strval($this->version))->prepend('v')->__toString();
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
* @property Collection<int, Anime> $anime
|
||||
* @property Collection<int, Artist> $artists
|
||||
* @property int|null $external_id
|
||||
* @property Uri|null $link
|
||||
* @property Uri $link
|
||||
* @property int $resource_id
|
||||
* @property ResourceSite|null $site
|
||||
* @property ResourceSite $site
|
||||
* @property Collection<int, Song> $songs
|
||||
* @property Collection<int, Studio> $studios
|
||||
*
|
||||
|
||||
@@ -28,7 +28,7 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
/**
|
||||
* @property Collection<int, Anime> $anime
|
||||
* @property Collection<int, Artist> $artists
|
||||
* @property ImageFacet|null $facet
|
||||
* @property ImageFacet $facet
|
||||
* @property int $image_id
|
||||
* @property string $link
|
||||
* @property string $mimetype
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Models\Wiki\Song\Performance;
|
||||
use App\Pivots\Morph\Resourceable;
|
||||
use App\Pivots\Wiki\ArtistSong;
|
||||
use Database\Factories\Wiki\SongFactory;
|
||||
use Deprecated;
|
||||
use Elastic\ScoutDriverPlus\Searchable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -131,6 +132,7 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
|
||||
/**
|
||||
* @return BelongsToMany<Artist, $this, ArtistSong>
|
||||
*/
|
||||
#[Deprecated]
|
||||
public function artists(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Artist::class, ArtistSong::TABLE, ArtistSong::ATTRIBUTE_SONG, ArtistSong::ATTRIBUTE_ARTIST)
|
||||
|
||||
@@ -30,7 +30,7 @@ use OwenIt\Auditing\Contracts\Auditable;
|
||||
* @property string $artist_type
|
||||
* @property int $artist_id
|
||||
* @property Artist|Membership $artist
|
||||
* @property int|null $relevance
|
||||
* @property int $relevance
|
||||
* @property Song $song
|
||||
*
|
||||
* @method static PerformanceFactory factory(...$parameters)
|
||||
@@ -100,6 +100,15 @@ class Performance extends BaseModel implements Auditable, SoftDeletable
|
||||
Performance::ATTRIBUTE_RELEVANCE,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
Performance::ATTRIBUTE_RELEVANCE => 1,
|
||||
];
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return strval($this->getKey());
|
||||
|
||||
@@ -159,6 +159,15 @@ class Video extends BaseModel implements Auditable, HasAggregateViews, SoftDelet
|
||||
Video::ATTRIBUTE_TAGS,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
Video::ATTRIBUTE_OVERLAP => VideoOverlap::NONE->value,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
* @property Model&HasImages&Nameable $imageable
|
||||
* @property string $imageable_type
|
||||
* @property int $imageable_id
|
||||
* @property int|null $depth
|
||||
* @property int $depth
|
||||
* @property Image $image
|
||||
* @property int $image_id
|
||||
*
|
||||
@@ -86,6 +86,15 @@ class Imageable extends BaseMorphPivot
|
||||
Imageable::ATTRIBUTE_IMAGEABLE_ID,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
Imageable::ATTRIBUTE_DEPTH => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @property Artist $member
|
||||
* @property int $member_id
|
||||
* @property string|null $notes
|
||||
* @property int|null $relevance
|
||||
* @property int $relevance
|
||||
*
|
||||
* @method static ArtistMemberFactory factory(...$parameters)
|
||||
*/
|
||||
@@ -72,6 +72,15 @@ class ArtistMember extends BasePivot
|
||||
ArtistMember::ATTRIBUTE_RELEVANCE,
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
ArtistMember::ATTRIBUTE_RELEVANCE => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the composite primary key for the pivot.
|
||||
*
|
||||
|
||||
@@ -35,4 +35,26 @@ class FeaturedThemeFactory extends Factory
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => fake()->dateTimeBetween('+1 day', '+1 year')->format(AllowedDateFormat::YMDHISU->value),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the featured theme time to past.
|
||||
*/
|
||||
public function past(): static
|
||||
{
|
||||
return $this->state([
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => fake()->dateTimeBetween('-2 years', '-1 year')->format(AllowedDateFormat::YMDHISU->value),
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => fake()->dateTimeBetween('-3 years', '-2 years')->format(AllowedDateFormat::YMDHISU->value),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the featured theme time to future.
|
||||
*/
|
||||
public function future(): static
|
||||
{
|
||||
return $this->state([
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => fake()->dateTimeBetween('+1 year', '+2 years')->format(AllowedDateFormat::YMDHISU->value),
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => fake()->dateTimeBetween('+1 day', '+1 year')->format(AllowedDateFormat::YMDHISU->value),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ return new class extends Migration
|
||||
$table->boolean('subbed')->default(false);
|
||||
$table->boolean('lyrics')->default(false);
|
||||
$table->boolean('uncen')->default(false);
|
||||
$table->integer('overlap')->default(0);
|
||||
$table->integer('overlap');
|
||||
$table->integer('source')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ return new class extends Migration
|
||||
$table->string('name');
|
||||
$table->integer('year')->nullable();
|
||||
$table->integer('season')->nullable();
|
||||
$table->integer('media_format')->default(0);
|
||||
$table->integer('media_format')->nullable();
|
||||
$table->text('synopsis')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ return new class extends Migration
|
||||
$table->id('resource_id');
|
||||
$table->timestamps(6);
|
||||
$table->softDeletes(precision: 6);
|
||||
$table->integer('site')->nullable();
|
||||
$table->string('link')->nullable();
|
||||
$table->integer('site');
|
||||
$table->string('link');
|
||||
$table->integer('external_id')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ return new class extends Migration
|
||||
$table->id('theme_id');
|
||||
$table->timestamps(6);
|
||||
$table->softDeletes(precision: 6);
|
||||
$table->integer('type')->nullable();
|
||||
$table->integer('type');
|
||||
$table->integer('sequence')->nullable();
|
||||
$table->string('slug');
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ return new class extends Migration
|
||||
$table->id('entry_id');
|
||||
$table->timestamps(6);
|
||||
$table->softDeletes(precision: 6);
|
||||
$table->integer('version')->nullable();
|
||||
$table->integer('version');
|
||||
$table->string('episodes')->nullable();
|
||||
$table->boolean('nsfw')->default(false);
|
||||
$table->boolean('spoiler')->default(false);
|
||||
|
||||
@@ -19,7 +19,7 @@ return new class extends Migration
|
||||
$table->timestamps(6);
|
||||
$table->softDeletes(precision: 6);
|
||||
$table->string('text')->nullable();
|
||||
$table->integer('type')->default(0);
|
||||
$table->integer('type');
|
||||
|
||||
$table->unsignedBigInteger('anime_id');
|
||||
$table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete();
|
||||
|
||||
@@ -19,7 +19,7 @@ return new class extends Migration
|
||||
$table->timestamps(6);
|
||||
$table->softDeletes(precision: 6);
|
||||
$table->string('path');
|
||||
$table->integer('facet')->nullable();
|
||||
$table->integer('facet');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ return new class extends Migration
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->boolean('default')->default(false);
|
||||
$table->string('color')->nullable();
|
||||
$table->integer('priority')->nullable();
|
||||
$table->integer('priority');
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
|
||||
@@ -17,8 +17,8 @@ return new class extends Migration
|
||||
Schema::create('featured_themes', function (Blueprint $table) {
|
||||
$table->id('featured_theme_id');
|
||||
$table->timestamps(6);
|
||||
$table->timestamp('start_at', 6)->nullable();
|
||||
$table->timestamp('end_at', 6)->nullable();
|
||||
$table->timestamp('start_at', 6);
|
||||
$table->timestamp('end_at', 6);
|
||||
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
|
||||
|
||||
@@ -19,10 +19,10 @@ return new class extends Migration
|
||||
$table->id('profile_id');
|
||||
$table->string('name');
|
||||
$table->integer('site');
|
||||
$table->integer('visibility')->default(1);
|
||||
$table->integer('visibility');
|
||||
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
|
||||
|
||||
$table->timestamp('synced_at', 6)->nullable();
|
||||
$table->integer('external_user_id')->nullable();
|
||||
|
||||
@@ -20,7 +20,7 @@ return new class extends Migration
|
||||
$table->string('name');
|
||||
|
||||
$table->unsignedBigInteger('anime_id');
|
||||
$table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete();
|
||||
$table->foreign('anime_id')->references('anime_id')->on('anime');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ return new class extends Migration
|
||||
$table->bigIncrements('id');
|
||||
$table->string('batch_id');
|
||||
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
|
||||
|
||||
$table->string('name');
|
||||
$table->morphs('actionable');
|
||||
|
||||
@@ -19,7 +19,7 @@ return new class extends Migration
|
||||
$table->foreign('image_id')->references('image_id')->on('images')->cascadeOnDelete();
|
||||
|
||||
$table->morphs('imageable');
|
||||
$table->integer('depth')->nullable();
|
||||
$table->integer('depth');
|
||||
|
||||
$table->timestamps(6);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasColumn('performances', 'relevance')) {
|
||||
Schema::table('performances', function (Blueprint $table) {
|
||||
$table->integer('relevance')->nullable()->after('as');
|
||||
$table->integer('relevance')->after('as');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ return new class extends Migration
|
||||
{
|
||||
if (! Schema::hasColumns('announcements', ['start_at', 'end_at'])) {
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->timestamp('start_at', 6)->nullable()->after('updated_at');
|
||||
$table->timestamp('end_at', 6)->nullable()->after('start_at');
|
||||
$table->timestamp('start_at', 6)->after('updated_at');
|
||||
$table->timestamp('end_at', 6)->after('start_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ return [
|
||||
ActionLogStatus::FINISHED->name => 'Finished',
|
||||
],
|
||||
AnimeMediaFormat::class => [
|
||||
AnimeMediaFormat::UNKNOWN->name => 'Unknown',
|
||||
AnimeMediaFormat::TV->name => 'TV',
|
||||
AnimeMediaFormat::TV_SHORT->name => 'TV Short',
|
||||
AnimeMediaFormat::OVA->name => 'OVA',
|
||||
|
||||
@@ -30,26 +30,6 @@ test('not found if no featured themes', function () {
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('not found if theme start at null', function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => null,
|
||||
]);
|
||||
|
||||
$response = get(route('api.featuredtheme.current.show'));
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('not found if theme end at null', function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => null,
|
||||
]);
|
||||
|
||||
$response = get(route('api.featuredtheme.current.show'));
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('not found if theme start at after now', function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => fake()->dateTimeBetween('+1 day', '+1 year'),
|
||||
@@ -72,27 +52,11 @@ test('not found if theme end at before now', function () {
|
||||
|
||||
test('default', function () {
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => null,
|
||||
]);
|
||||
FeaturedTheme::factory()->future()->create();
|
||||
});
|
||||
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => null,
|
||||
]);
|
||||
});
|
||||
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => fake()->dateTimeBetween('+1 day', '+1 year'),
|
||||
]);
|
||||
});
|
||||
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_END_AT => fake()->dateTimeBetween('-1 year', '-1 day'),
|
||||
]);
|
||||
FeaturedTheme::factory()->past()->create();
|
||||
});
|
||||
|
||||
$currentTheme = FeaturedTheme::factory()->create();
|
||||
|
||||
@@ -44,15 +44,7 @@ test('default', function () {
|
||||
$featuredThemes = FeaturedTheme::factory()->count($publicCount)->create();
|
||||
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => fake()->dateTimeBetween('+1 day', '+1 year'),
|
||||
]);
|
||||
});
|
||||
|
||||
Collection::times(fake()->randomDigitNotNull(), function () {
|
||||
FeaturedTheme::factory()->create([
|
||||
FeaturedTheme::ATTRIBUTE_START_AT => null,
|
||||
]);
|
||||
FeaturedTheme::factory()->future();
|
||||
});
|
||||
|
||||
$response = get(route('api.featuredtheme.index'));
|
||||
|
||||
Reference in New Issue
Block a user