diff --git a/app/Concerns/Models/SoftDeletes.php b/app/Concerns/Models/SoftDeletes.php index 08ece5e1e..46ea394bd 100644 --- a/app/Concerns/Models/SoftDeletes.php +++ b/app/Concerns/Models/SoftDeletes.php @@ -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 diff --git a/app/Enums/Models/Wiki/AnimeMediaFormat.php b/app/Enums/Models/Wiki/AnimeMediaFormat.php index 3bd07d5bb..a01e88c91 100644 --- a/app/Enums/Models/Wiki/AnimeMediaFormat.php +++ b/app/Enums/Models/Wiki/AnimeMediaFormat.php @@ -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; } diff --git a/app/Enums/Models/Wiki/VideoSource.php b/app/Enums/Models/Wiki/VideoSource.php index afb9330a7..5ba9882cd 100644 --- a/app/Enums/Models/Wiki/VideoSource.php +++ b/app/Enums/Models/Wiki/VideoSource.php @@ -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 { diff --git a/app/Events/Wiki/Artist/ArtistDeleted.php b/app/Events/Wiki/Artist/ArtistDeleted.php index e0ff9af3f..4c0ffdf13 100644 --- a/app/Events/Wiki/Artist/ArtistDeleted.php +++ b/app/Events/Wiki/Artist/ArtistDeleted.php @@ -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(); diff --git a/app/Events/Wiki/Artist/ArtistForceDeleted.php b/app/Events/Wiki/Artist/ArtistForceDeleted.php index 2b955535f..647cae335 100644 --- a/app/Events/Wiki/Artist/ArtistForceDeleted.php +++ b/app/Events/Wiki/Artist/ArtistForceDeleted.php @@ -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(); diff --git a/app/Events/Wiki/Artist/ArtistRestored.php b/app/Events/Wiki/Artist/ArtistRestored.php index 38aaace7c..021aead44 100644 --- a/app/Events/Wiki/Artist/ArtistRestored.php +++ b/app/Events/Wiki/Artist/ArtistRestored.php @@ -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(); }); diff --git a/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeEndAtField.php b/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeEndAtField.php index b906ae36b..06d78719b 100644 --- a/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeEndAtField.php +++ b/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeEndAtField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeStartAtField.php b/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeStartAtField.php index e70a90cea..93732d909 100644 --- a/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeStartAtField.php +++ b/app/GraphQL/Schema/Fields/Admin/FeaturedTheme/FeaturedThemeStartAtField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Auth/Role/RolePriorityField.php b/app/GraphQL/Schema/Fields/Auth/Role/RolePriorityField.php index 3e049b2f4..ce9b58d52 100644 --- a/app/GraphQL/Schema/Fields/Auth/Role/RolePriorityField.php +++ b/app/GraphQL/Schema/Fields/Auth/Role/RolePriorityField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Pivot/Morph/Imageable/ImageableDepthField.php b/app/GraphQL/Schema/Fields/Pivot/Morph/Imageable/ImageableDepthField.php index ba8388458..2e6a5deae 100644 --- a/app/GraphQL/Schema/Fields/Pivot/Morph/Imageable/ImageableDepthField.php +++ b/app/GraphQL/Schema/Fields/Pivot/Morph/Imageable/ImageableDepthField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Pivot/Wiki/ArtistMember/ArtistMemberRelevanceField.php b/app/GraphQL/Schema/Fields/Pivot/Wiki/ArtistMember/ArtistMemberRelevanceField.php index 0ccb24e67..b1d471d8b 100644 --- a/app/GraphQL/Schema/Fields/Pivot/Wiki/ArtistMember/ArtistMemberRelevanceField.php +++ b/app/GraphQL/Schema/Fields/Pivot/Wiki/ArtistMember/ArtistMemberRelevanceField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Anime/AnimeSynonym/AnimeSynonymTypeField.php b/app/GraphQL/Schema/Fields/Wiki/Anime/AnimeSynonym/AnimeSynonymTypeField.php index fba3c79ce..c9a54d000 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Anime/AnimeSynonym/AnimeSynonymTypeField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Anime/AnimeSynonym/AnimeSynonymTypeField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Anime/Theme/Entry/AnimeThemeEntryVersionField.php b/app/GraphQL/Schema/Fields/Wiki/Anime/Theme/Entry/AnimeThemeEntryVersionField.php index 1422a2434..e1d778b38 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Anime/Theme/Entry/AnimeThemeEntryVersionField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Anime/Theme/Entry/AnimeThemeEntryVersionField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Song/Performance/PerformanceRelevanceField.php b/app/GraphQL/Schema/Fields/Wiki/Song/Performance/PerformanceRelevanceField.php index 8cee01003..d4cad9b33 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Song/Performance/PerformanceRelevanceField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Song/Performance/PerformanceRelevanceField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Video/VideoMimetypeField.php b/app/GraphQL/Schema/Fields/Wiki/Video/VideoMimetypeField.php index 53835cd13..b8e28181c 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Video/VideoMimetypeField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Video/VideoMimetypeField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Video/VideoOverlapField.php b/app/GraphQL/Schema/Fields/Wiki/Video/VideoOverlapField.php index c991fba69..0f3f3429b 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Video/VideoOverlapField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Video/VideoOverlapField.php @@ -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 diff --git a/app/GraphQL/Schema/Fields/Wiki/Video/VideoSizeField.php b/app/GraphQL/Schema/Fields/Wiki/Video/VideoSizeField.php index 935a5d0b4..d90057e3b 100644 --- a/app/GraphQL/Schema/Fields/Wiki/Video/VideoSizeField.php +++ b/app/GraphQL/Schema/Fields/Wiki/Video/VideoSizeField.php @@ -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 diff --git a/app/GraphQL/Schema/Types/Admin/FeaturedThemeType.php b/app/GraphQL/Schema/Types/Admin/FeaturedThemeType.php index 8fe9cd049..3dc04c061 100644 --- a/app/GraphQL/Schema/Types/Admin/FeaturedThemeType.php +++ b/app/GraphQL/Schema/Types/Admin/FeaturedThemeType.php @@ -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), ]; } diff --git a/app/Http/Api/Field/Admin/Announcement/AnnouncementEndAtField.php b/app/Http/Api/Field/Admin/Announcement/AnnouncementEndAtField.php new file mode 100644 index 000000000..ddc138932 --- /dev/null +++ b/app/Http/Api/Field/Admin/Announcement/AnnouncementEndAtField.php @@ -0,0 +1,56 @@ +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(), + ]; + } +} diff --git a/app/Http/Api/Field/Admin/Announcement/AnnouncementStartAtField.php b/app/Http/Api/Field/Admin/Announcement/AnnouncementStartAtField.php new file mode 100644 index 000000000..86e92f44b --- /dev/null +++ b/app/Http/Api/Field/Admin/Announcement/AnnouncementStartAtField.php @@ -0,0 +1,55 @@ +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(), + ]; + } +} diff --git a/app/Http/Api/Schema/Admin/AnnouncementSchema.php b/app/Http/Api/Schema/Admin/AnnouncementSchema.php index c9b3fbc2d..53a61f27c 100644 --- a/app/Http/Api/Schema/Admin/AnnouncementSchema.php +++ b/app/Http/Api/Schema/Admin/AnnouncementSchema.php @@ -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), ]; } diff --git a/app/Models/Admin/ActionLog.php b/app/Models/Admin/ActionLog.php index 1f5744333..0e7a15731 100644 --- a/app/Models/Admin/ActionLog.php +++ b/app/Models/Admin/ActionLog.php @@ -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 diff --git a/app/Models/Admin/Announcement.php b/app/Models/Admin/Announcement.php index f56d8f18c..3bfe764aa 100644 --- a/app/Models/Admin/Announcement.php +++ b/app/Models/Admin/Announcement.php @@ -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 current() diff --git a/app/Models/Admin/FeaturedTheme.php b/app/Models/Admin/FeaturedTheme.php index bdeb91822..07a40313c 100644 --- a/app/Models/Admin/FeaturedTheme.php +++ b/app/Models/Admin/FeaturedTheme.php @@ -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 diff --git a/app/Models/Auth/Role.php b/app/Models/Auth/Role.php index d9e51488b..1a8098121 100644 --- a/app/Models/Auth/Role.php +++ b/app/Models/Auth/Role.php @@ -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 + */ + protected $attributes = [ + Role::ATTRIBUTE_PRIORITY => 0, + ]; + /** * Get the attributes that should be cast. * diff --git a/app/Models/Wiki/Anime.php b/app/Models/Wiki/Anime.php index d6411c56e..f7427a32f 100644 --- a/app/Models/Wiki/Anime.php +++ b/app/Models/Wiki/Anime.php @@ -46,7 +46,7 @@ use OwenIt\Auditing\Contracts\Auditable; * @property DiscordThread|null $discordthread * @property Collection $externalentries * @property Collection $images - * @property AnimeMediaFormat $media_format + * @property AnimeMediaFormat|null $media_format * @property string $name * @property Collection $resources * @property AnimeSeason|null $season diff --git a/app/Models/Wiki/Anime/AnimeSynonym.php b/app/Models/Wiki/Anime/AnimeSynonym.php index 3e6fe7658..7a33bbaea 100644 --- a/app/Models/Wiki/Anime/AnimeSynonym.php +++ b/app/Models/Wiki/Anime/AnimeSynonym.php @@ -74,6 +74,15 @@ class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable AnimeSynonym::ATTRIBUTE_TYPE, ]; + /** + * The model's default values for attributes. + * + * @var array + */ + protected $attributes = [ + AnimeSynonym::ATTRIBUTE_TYPE => AnimeSynonymType::OTHER->value, + ]; + /** * The event map for the model. * diff --git a/app/Models/Wiki/Anime/AnimeTheme.php b/app/Models/Wiki/Anime/AnimeTheme.php index 9b2cde174..966da65f0 100644 --- a/app/Models/Wiki/Anime/AnimeTheme.php +++ b/app/Models/Wiki/Anime/AnimeTheme.php @@ -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) */ diff --git a/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php b/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php index daceec73b..0b77f01c3 100644 --- a/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php +++ b/app/Models/Wiki/Anime/Theme/AnimeThemeEntry.php @@ -57,7 +57,7 @@ use Znck\Eloquent\Traits\BelongsToThrough as ZnckBelongsToThrough; * @property Collection $resources * @property bool $spoiler * @property int $theme_id - * @property int|null $version + * @property int $version * @property Collection $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 + */ + 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; } diff --git a/app/Models/Wiki/ExternalResource.php b/app/Models/Wiki/ExternalResource.php index eb87e1421..ee1694c28 100644 --- a/app/Models/Wiki/ExternalResource.php +++ b/app/Models/Wiki/ExternalResource.php @@ -28,9 +28,9 @@ use OwenIt\Auditing\Contracts\Auditable; * @property Collection $anime * @property Collection $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 $songs * @property Collection $studios * diff --git a/app/Models/Wiki/Image.php b/app/Models/Wiki/Image.php index 02ed78bd5..f962e5af8 100644 --- a/app/Models/Wiki/Image.php +++ b/app/Models/Wiki/Image.php @@ -28,7 +28,7 @@ use OwenIt\Auditing\Contracts\Auditable; /** * @property Collection $anime * @property Collection $artists - * @property ImageFacet|null $facet + * @property ImageFacet $facet * @property int $image_id * @property string $link * @property string $mimetype diff --git a/app/Models/Wiki/Song.php b/app/Models/Wiki/Song.php index 553d13387..9ae4a8aed 100644 --- a/app/Models/Wiki/Song.php +++ b/app/Models/Wiki/Song.php @@ -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 */ + #[Deprecated] public function artists(): BelongsToMany { return $this->belongsToMany(Artist::class, ArtistSong::TABLE, ArtistSong::ATTRIBUTE_SONG, ArtistSong::ATTRIBUTE_ARTIST) diff --git a/app/Models/Wiki/Song/Performance.php b/app/Models/Wiki/Song/Performance.php index 1a51e9338..653cbd758 100644 --- a/app/Models/Wiki/Song/Performance.php +++ b/app/Models/Wiki/Song/Performance.php @@ -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 + */ + protected $attributes = [ + Performance::ATTRIBUTE_RELEVANCE => 1, + ]; + public function getName(): string { return strval($this->getKey()); diff --git a/app/Models/Wiki/Video.php b/app/Models/Wiki/Video.php index 731f48e89..b2649c450 100644 --- a/app/Models/Wiki/Video.php +++ b/app/Models/Wiki/Video.php @@ -159,6 +159,15 @@ class Video extends BaseModel implements Auditable, HasAggregateViews, SoftDelet Video::ATTRIBUTE_TAGS, ]; + /** + * The model's default values for attributes. + * + * @var array + */ + protected $attributes = [ + Video::ATTRIBUTE_OVERLAP => VideoOverlap::NONE->value, + ]; + /** * Get the attributes that should be cast. * diff --git a/app/Pivots/Morph/Imageable.php b/app/Pivots/Morph/Imageable.php index 888bc4b5a..d59fa238e 100644 --- a/app/Pivots/Morph/Imageable.php +++ b/app/Pivots/Morph/Imageable.php @@ -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 + */ + protected $attributes = [ + Imageable::ATTRIBUTE_DEPTH => 1, + ]; + /** * Get the attributes that should be cast. * diff --git a/app/Pivots/Wiki/ArtistMember.php b/app/Pivots/Wiki/ArtistMember.php index 50dc9fe76..f96712614 100644 --- a/app/Pivots/Wiki/ArtistMember.php +++ b/app/Pivots/Wiki/ArtistMember.php @@ -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 + */ + protected $attributes = [ + ArtistMember::ATTRIBUTE_RELEVANCE => 1, + ]; + /** * Get the composite primary key for the pivot. * diff --git a/database/factories/Admin/FeaturedThemeFactory.php b/database/factories/Admin/FeaturedThemeFactory.php index 0a330bafd..5f7d2d817 100644 --- a/database/factories/Admin/FeaturedThemeFactory.php +++ b/database/factories/Admin/FeaturedThemeFactory.php @@ -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), + ]); + } } diff --git a/database/migrations/2017_11_26_225409_create_videos_table.php b/database/migrations/2017_11_26_225409_create_videos_table.php index d6c76d869..0d0c70c63 100644 --- a/database/migrations/2017_11_26_225409_create_videos_table.php +++ b/database/migrations/2017_11_26_225409_create_videos_table.php @@ -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(); }); } diff --git a/database/migrations/2020_05_05_044925_create_anime_table.php b/database/migrations/2020_05_05_044925_create_anime_table.php index b1d9d8f78..9c65c85d2 100644 --- a/database/migrations/2020_05_05_044925_create_anime_table.php +++ b/database/migrations/2020_05_05_044925_create_anime_table.php @@ -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(); }); } diff --git a/database/migrations/2020_05_05_045017_create_resources_table.php b/database/migrations/2020_05_05_045017_create_resources_table.php index e7fca968f..9a158a818 100644 --- a/database/migrations/2020_05_05_045017_create_resources_table.php +++ b/database/migrations/2020_05_05_045017_create_resources_table.php @@ -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(); }); } diff --git a/database/migrations/2020_05_05_045028_create_anime_themes_table.php b/database/migrations/2020_05_05_045028_create_anime_themes_table.php index 14a9462e6..4a36e3cd3 100644 --- a/database/migrations/2020_05_05_045028_create_anime_themes_table.php +++ b/database/migrations/2020_05_05_045028_create_anime_themes_table.php @@ -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'); diff --git a/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php b/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php index 1a18c6a95..bc2020371 100644 --- a/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php +++ b/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php @@ -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); diff --git a/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php b/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php index d5d9e10a8..70e8e7a62 100644 --- a/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php +++ b/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php @@ -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(); diff --git a/database/migrations/2020_11_24_231534_create_image_table.php b/database/migrations/2020_11_24_231534_create_image_table.php index 2992a4edc..fae4adc83 100644 --- a/database/migrations/2020_11_24_231534_create_image_table.php +++ b/database/migrations/2020_11_24_231534_create_image_table.php @@ -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'); }); } } diff --git a/database/migrations/2022_05_09_032230_create_permission_tables.php b/database/migrations/2022_05_09_032230_create_permission_tables.php index a7ff4987a..8b9084d91 100644 --- a/database/migrations/2022_05_09_032230_create_permission_tables.php +++ b/database/migrations/2022_05_09_032230_create_permission_tables.php @@ -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']); diff --git a/database/migrations/2023_04_24_002635_create_featured_theme_table.php b/database/migrations/2023_04_24_002635_create_featured_theme_table.php index 917114427..708ae8227 100644 --- a/database/migrations/2023_04_24_002635_create_featured_theme_table.php +++ b/database/migrations/2023_04_24_002635_create_featured_theme_table.php @@ -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(); diff --git a/database/migrations/2024_03_10_181149_create_external_profile_table.php b/database/migrations/2024_03_10_181149_create_external_profile_table.php index 410ad79e9..b1c1d85bd 100644 --- a/database/migrations/2024_03_10_181149_create_external_profile_table.php +++ b/database/migrations/2024_03_10_181149_create_external_profile_table.php @@ -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(); diff --git a/database/migrations/2024_05_31_052841_create_discord_threads_table.php b/database/migrations/2024_05_31_052841_create_discord_threads_table.php index d59ed649a..c9844e730 100644 --- a/database/migrations/2024_05_31_052841_create_discord_threads_table.php +++ b/database/migrations/2024_05_31_052841_create_discord_threads_table.php @@ -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'); }); } } diff --git a/database/migrations/2024_06_25_145723_create_action_logs_table.php b/database/migrations/2024_06_25_145723_create_action_logs_table.php index 9d7c10935..a6aa71c3a 100644 --- a/database/migrations/2024_06_25_145723_create_action_logs_table.php +++ b/database/migrations/2024_06_25_145723_create_action_logs_table.php @@ -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'); diff --git a/database/migrations/2025_08_16_025830_create_imageables_table.php b/database/migrations/2025_08_16_025830_create_imageables_table.php index 0ac64546d..9fb41b0dd 100644 --- a/database/migrations/2025_08_16_025830_create_imageables_table.php +++ b/database/migrations/2025_08_16_025830_create_imageables_table.php @@ -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); diff --git a/database/migrations/2025_10_25_033138_add_relevance_to_performances.php b/database/migrations/2025_10_25_033138_add_relevance_to_performances.php index edb715a0f..bfb45a969 100644 --- a/database/migrations/2025_10_25_033138_add_relevance_to_performances.php +++ b/database/migrations/2025_10_25_033138_add_relevance_to_performances.php @@ -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'); }); } } diff --git a/database/migrations/2025_12_31_032033_add_dates_to_announcements_table.php b/database/migrations/2025_12_31_032033_add_dates_to_announcements_table.php index 449770dfc..794aa1051 100644 --- a/database/migrations/2025_12_31_032033_add_dates_to_announcements_table.php +++ b/database/migrations/2025_12_31_032033_add_dates_to_announcements_table.php @@ -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'); }); } } diff --git a/lang/en/enums.php b/lang/en/enums.php index 3881f3c46..b810ee7df 100644 --- a/lang/en/enums.php +++ b/lang/en/enums.php @@ -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', diff --git a/tests/Feature/Http/Api/Admin/FeaturedTheme/CurrentFeaturedThemeShowTest.php b/tests/Feature/Http/Api/Admin/FeaturedTheme/CurrentFeaturedThemeShowTest.php index 56be69a3b..73221f0db 100644 --- a/tests/Feature/Http/Api/Admin/FeaturedTheme/CurrentFeaturedThemeShowTest.php +++ b/tests/Feature/Http/Api/Admin/FeaturedTheme/CurrentFeaturedThemeShowTest.php @@ -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(); diff --git a/tests/Feature/Http/Api/Admin/FeaturedTheme/FeaturedThemeIndexTest.php b/tests/Feature/Http/Api/Admin/FeaturedTheme/FeaturedThemeIndexTest.php index 6b59718da..3565f6c2b 100644 --- a/tests/Feature/Http/Api/Admin/FeaturedTheme/FeaturedThemeIndexTest.php +++ b/tests/Feature/Http/Api/Admin/FeaturedTheme/FeaturedThemeIndexTest.php @@ -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'));