feat: unguard models (#1167)

This commit is contained in:
Kyrch
2026-04-17 10:45:33 -03:00
committed by GitHub
parent 3ae5898927
commit 884f6921a0
42 changed files with 2 additions and 478 deletions
-21
View File
@@ -73,27 +73,6 @@ class ActionLog extends Model implements Nameable
final public const string RELATION_USER = 'user';
final public const string RELATION_TARGET = 'target';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ActionLog::ATTRIBUTE_BATCH_ID,
ActionLog::ATTRIBUTE_NAME,
ActionLog::ATTRIBUTE_USER,
ActionLog::ATTRIBUTE_ACTIONABLE_TYPE,
ActionLog::ATTRIBUTE_ACTIONABLE_ID,
ActionLog::ATTRIBUTE_TARGET_TYPE,
ActionLog::ATTRIBUTE_TARGET_ID,
ActionLog::ATTRIBUTE_MODEL_TYPE,
ActionLog::ATTRIBUTE_MODEL_ID,
ActionLog::ATTRIBUTE_FIELDS,
ActionLog::ATTRIBUTE_STATUS,
ActionLog::ATTRIBUTE_EXCEPTION,
ActionLog::ATTRIBUTE_FINISHED_AT,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -53,17 +53,6 @@ class Announcement extends BaseModel implements Auditable
'updated' => AnnouncementUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Announcement::ATTRIBUTE_CONTENT,
Announcement::ATTRIBUTE_END_AT,
Announcement::ATTRIBUTE_START_AT,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -50,16 +50,6 @@ class Dump extends BaseModel
'updated' => DumpUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Dump::ATTRIBUTE_PATH,
Dump::ATTRIBUTE_PUBLIC,
];
/**
* Get the attributes that should be cast.
*
-9
View File
@@ -49,15 +49,6 @@ class Feature extends BaseModel
'updated' => FeatureUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Feature::ATTRIBUTE_VALUE,
];
/**
* Get the attributes that should be cast.
*
-13
View File
@@ -72,19 +72,6 @@ class FeaturedTheme extends BaseModel implements Auditable
'updated' => FeaturedThemeUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
FeaturedTheme::ATTRIBUTE_END_AT,
FeaturedTheme::ATTRIBUTE_ENTRY,
FeaturedTheme::ATTRIBUTE_START_AT,
FeaturedTheme::ATTRIBUTE_USER,
FeaturedTheme::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
-12
View File
@@ -127,18 +127,6 @@ class User extends Authenticatable implements Auditable, FilamentUser, HasAvatar
'updated' => UserUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
User::ATTRIBUTE_EMAIL,
User::ATTRIBUTE_NAME,
User::ATTRIBUTE_PASSWORD,
User::ATTRIBUTE_EMAIL_VERIFIED_AT,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -51,17 +51,6 @@ class DiscordThread extends BaseModel
'updated' => DiscordThreadUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
DiscordThread::ATTRIBUTE_ANIME,
DiscordThread::ATTRIBUTE_ID,
DiscordThread::ATTRIBUTE_NAME,
];
/**
* Get the attributes that should be cast.
*
-13
View File
@@ -79,19 +79,6 @@ class Page extends BaseModel implements Auditable, SoftDeletable
'updated' => PageUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Page::ATTRIBUTE_BODY,
Page::ATTRIBUTE_NAME,
Page::ATTRIBUTE_NEXT,
Page::ATTRIBUTE_PREVIOUS,
Page::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
-13
View File
@@ -43,19 +43,6 @@ class ExternalEntry extends BaseModel
final public const string RELATION_PROFILE = 'externalprofile';
final public const string RELATION_USER = 'externalprofile.user';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ExternalEntry::ATTRIBUTE_ANIME,
ExternalEntry::ATTRIBUTE_PROFILE,
ExternalEntry::ATTRIBUTE_IS_FAVORITE,
ExternalEntry::ATTRIBUTE_SCORE,
ExternalEntry::ATTRIBUTE_STATUS,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -47,17 +47,6 @@ class ExternalToken extends BaseModel
final public const string RELATION_USER = 'externalprofile.user';
final public const string RELATION_USER_SHALLOW = 'user';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ExternalToken::ATTRIBUTE_ACCESS_TOKEN,
ExternalToken::ATTRIBUTE_PROFILE,
ExternalToken::ATTRIBUTE_REFRESH_TOKEN,
];
/**
* Get the attributes that should be cast.
*
-14
View File
@@ -83,20 +83,6 @@ class ExternalProfile extends BaseModel
'updated' => ExternalProfileUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ExternalProfile::ATTRIBUTE_EXTERNAL_USER_ID,
ExternalProfile::ATTRIBUTE_NAME,
ExternalProfile::ATTRIBUTE_SITE,
ExternalProfile::ATTRIBUTE_SYNCED_AT,
ExternalProfile::ATTRIBUTE_VISIBILITY,
ExternalProfile::ATTRIBUTE_USER,
];
/**
* Get the attributes that should be cast.
*
-12
View File
@@ -85,18 +85,6 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
'updated' => PlaylistUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Playlist::ATTRIBUTE_DESCRIPTION,
Playlist::ATTRIBUTE_NAME,
Playlist::ATTRIBUTE_USER,
Playlist::ATTRIBUTE_VISIBILITY,
];
/**
* Get the route key for the model.
*
@@ -80,18 +80,6 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
'updated' => TrackUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
PlaylistTrack::ATTRIBUTE_ENTRY,
PlaylistTrack::ATTRIBUTE_PLAYLIST,
PlaylistTrack::ATTRIBUTE_POSITION,
PlaylistTrack::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -39,17 +39,6 @@ class Like extends BaseModel
final public const string RELATION_USER = 'user';
final public const string RELATION_LIKEABLE = 'likeable';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Like::ATTRIBUTE_USER,
Like::ATTRIBUTE_LIKEABLE_TYPE,
Like::ATTRIBUTE_LIKEABLE_ID,
];
/**
* Get the attributes that should be cast.
*
-2
View File
@@ -9,7 +9,6 @@ use App\Models\Auth\User;
use App\Models\BaseModel;
use App\Models\User\Submission\SubmissionComparison;
use App\Models\Wiki\Anime;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Builder;
@@ -37,7 +36,6 @@ use Illuminate\Support\Carbon;
*
* @method static Builder pending()
*/
#[Guarded([])]
#[Table(Submission::TABLE, Submission::ATTRIBUTE_ID)]
class Submission extends BaseModel
{
@@ -15,20 +15,6 @@ class SubmissionAnime extends Anime
{
use SubmissionModel;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Anime::ATTRIBUTE_NAME,
Anime::ATTRIBUTE_SEASON,
Anime::ATTRIBUTE_SLUG,
Anime::ATTRIBUTE_SYNOPSIS,
Anime::ATTRIBUTE_YEAR,
'format',
];
/**
* Get the attributes that should be cast.
*
@@ -6,14 +6,12 @@ namespace App\Models\User\Submission;
use App\Enums\Models\User\SubmissionComparisonAction;
use App\Models\User\Submission;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
#[Guarded([])]
#[Table(SubmissionComparison::TABLE, SubmissionComparison::ATTRIBUTE_ID)]
#[WithoutTimestamps]
class SubmissionComparison extends Model
-11
View File
@@ -39,17 +39,6 @@ class WatchHistory extends BaseModel
final public const string RELATION_USER = 'user';
final public const string RELATION_VIDEO = 'video';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
WatchHistory::ATTRIBUTE_ENTRY,
WatchHistory::ATTRIBUTE_USER,
WatchHistory::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
-14
View File
@@ -119,20 +119,6 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has
'updated' => AnimeUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Anime::ATTRIBUTE_NAME,
Anime::ATTRIBUTE_SEASON,
Anime::ATTRIBUTE_SLUG,
Anime::ATTRIBUTE_SYNOPSIS,
Anime::ATTRIBUTE_YEAR,
Anime::ATTRIBUTE_MEDIA_FORMAT,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -48,17 +48,6 @@ class AnimeSynonym extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_SERIES = 'anime.series';
final public const string RELATION_VIDEOS = 'anime.animethemes.animethemeentries.videos';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeSynonym::ATTRIBUTE_ANIME,
AnimeSynonym::ATTRIBUTE_TEXT,
AnimeSynonym::ATTRIBUTE_TYPE,
];
/**
* Get the attributes that should be cast.
*
-14
View File
@@ -102,20 +102,6 @@ class AnimeTheme extends BaseModel implements Auditable, InteractsWithSchema, So
'updated' => ThemeUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeTheme::ATTRIBUTE_ANIME,
AnimeTheme::ATTRIBUTE_GROUP,
AnimeTheme::ATTRIBUTE_SEQUENCE,
AnimeTheme::ATTRIBUTE_SLUG,
AnimeTheme::ATTRIBUTE_SONG,
AnimeTheme::ATTRIBUTE_TYPE,
];
/**
* Get the attributes that should be cast.
*
@@ -112,20 +112,6 @@ class AnimeThemeEntry extends BaseModel implements Auditable, HasAggregateLikes,
'updated' => EntryUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeThemeEntry::ATTRIBUTE_EPISODES,
AnimeThemeEntry::ATTRIBUTE_NOTES,
AnimeThemeEntry::ATTRIBUTE_NSFW,
AnimeThemeEntry::ATTRIBUTE_SPOILER,
AnimeThemeEntry::ATTRIBUTE_THEME,
AnimeThemeEntry::ATTRIBUTE_VERSION,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -101,17 +101,6 @@ class Artist extends BaseModel implements Auditable, HasImages, HasResources, Ha
'updated' => ArtistUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Artist::ATTRIBUTE_NAME,
Artist::ATTRIBUTE_SLUG,
Artist::ATTRIBUTE_INFORMATION,
];
/**
* Get the attributes that should be cast.
*
-13
View File
@@ -70,19 +70,6 @@ class Audio extends BaseModel implements Auditable, SoftDeletable, Streamable
'updated' => AudioUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Audio::ATTRIBUTE_BASENAME,
Audio::ATTRIBUTE_FILENAME,
Audio::ATTRIBUTE_MIMETYPE,
Audio::ATTRIBUTE_PATH,
Audio::ATTRIBUTE_SIZE,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -70,17 +70,6 @@ class ExternalResource extends BaseModel implements Auditable, SoftDeletable
'updated' => ExternalResourceUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ExternalResource::ATTRIBUTE_EXTERNAL_ID,
ExternalResource::ATTRIBUTE_LINK,
ExternalResource::ATTRIBUTE_SITE,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -59,16 +59,6 @@ class Group extends BaseModel implements Auditable, SoftDeletable
'updated' => GroupUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Group::ATTRIBUTE_NAME,
Group::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -76,16 +76,6 @@ class Image extends BaseModel implements Auditable, SoftDeletable
'updated' => ImageUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Image::ATTRIBUTE_FACET,
Image::ATTRIBUTE_PATH,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -68,16 +68,6 @@ class Series extends BaseModel implements Auditable, SoftDeletable
'updated' => SeriesUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Series::ATTRIBUTE_NAME,
Series::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -82,16 +82,6 @@ class Song extends BaseModel implements Auditable, HasResources, SoftDeletable
'updated' => SongUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Song::ATTRIBUTE_TITLE,
Song::ATTRIBUTE_TITLE_NATIVE,
];
/**
* Get the attributes that should be cast.
*
-16
View File
@@ -79,22 +79,6 @@ class Performance extends BaseModel implements Auditable, SoftDeletable, Sortabl
'updated' => PerformanceUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Performance::ATTRIBUTE_SONG,
Performance::ATTRIBUTE_ARTIST,
Performance::ATTRIBUTE_ALIAS,
Performance::ATTRIBUTE_AS,
Performance::ATTRIBUTE_MEMBER,
Performance::ATTRIBUTE_MEMBER_ALIAS,
Performance::ATTRIBUTE_MEMBER_AS,
Performance::ATTRIBUTE_RELEVANCE,
];
public $sortable = [
'order_column_name' => Performance::ATTRIBUTE_RELEVANCE,
];
-10
View File
@@ -74,16 +74,6 @@ class Studio extends BaseModel implements Auditable, HasImages, HasResources, So
'updated' => StudioUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Studio::ATTRIBUTE_NAME,
Studio::ATTRIBUTE_SLUG,
];
/**
* Get the attributes that should be cast.
*
-12
View File
@@ -55,18 +55,6 @@ class Synonym extends BaseModel implements Auditable, SoftDeletable
final public const string RELATION_SYNONYMABLE = 'synonymable';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Synonym::ATTRIBUTE_SYNONYMABLE_TYPE,
Synonym::ATTRIBUTE_SYNONYMABLE_ID,
Synonym::ATTRIBUTE_TEXT,
Synonym::ATTRIBUTE_TYPE,
];
/**
* The event map for the model.
*
-21
View File
@@ -124,27 +124,6 @@ class Video extends BaseModel implements Auditable, SoftDeletable, Streamable
'updated' => VideoUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Video::ATTRIBUTE_AUDIO,
Video::ATTRIBUTE_BASENAME,
Video::ATTRIBUTE_FILENAME,
Video::ATTRIBUTE_LYRICS,
Video::ATTRIBUTE_MIMETYPE,
Video::ATTRIBUTE_NC,
Video::ATTRIBUTE_OVERLAP,
Video::ATTRIBUTE_PATH,
Video::ATTRIBUTE_RESOLUTION,
Video::ATTRIBUTE_SIZE,
Video::ATTRIBUTE_SOURCE,
Video::ATTRIBUTE_SUBBED,
Video::ATTRIBUTE_UNCEN,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -65,16 +65,6 @@ class VideoScript extends BaseModel implements Auditable, InteractsWithSchema, S
'updated' => VideoScriptUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
VideoScript::ATTRIBUTE_PATH,
VideoScript::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
-11
View File
@@ -33,17 +33,6 @@ class PageRole extends BasePivot
final public const string RELATION_PAGE = 'page';
final public const string RELATION_ROLE = 'role';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
PageRole::ATTRIBUTE_PAGE,
PageRole::ATTRIBUTE_ROLE,
PageRole::ATTRIBUTE_TYPE,
];
/**
* Get the attributes that should be cast.
*
-12
View File
@@ -73,18 +73,6 @@ class Imageable extends BaseMorphPivot implements Auditable
'updated' => ImageableUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Imageable::ATTRIBUTE_DEPTH,
Imageable::ATTRIBUTE_IMAGE,
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
Imageable::ATTRIBUTE_IMAGEABLE_ID,
];
/**
* Get the attributes that should be cast.
*
-12
View File
@@ -75,18 +75,6 @@ class Resourceable extends BaseMorphPivot implements Auditable
'updated' => ResourceableUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
Resourceable::ATTRIBUTE_AS,
Resourceable::ATTRIBUTE_RESOURCE,
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -48,16 +48,6 @@ class AnimeSeries extends BasePivot implements Auditable
'deleted' => AnimeSeriesDeleted::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeSeries::ATTRIBUTE_ANIME,
AnimeSeries::ATTRIBUTE_SERIES,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -48,16 +48,6 @@ class AnimeStudio extends BasePivot implements Auditable
'deleted' => AnimeStudioDeleted::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeStudio::ATTRIBUTE_ANIME,
AnimeStudio::ATTRIBUTE_STUDIO,
];
/**
* Get the attributes that should be cast.
*
-10
View File
@@ -52,16 +52,6 @@ class AnimeThemeEntryVideo extends BasePivot implements Auditable
'deleted' => AnimeThemeEntryVideoDeleted::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeThemeEntryVideo::ATTRIBUTE_ENTRY,
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
-14
View File
@@ -57,20 +57,6 @@ class ArtistMember extends BasePivot implements Auditable
'updated' => ArtistMemberUpdated::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
ArtistMember::ATTRIBUTE_ALIAS,
ArtistMember::ATTRIBUTE_ARTIST,
ArtistMember::ATTRIBUTE_AS,
ArtistMember::ATTRIBUTE_MEMBER,
ArtistMember::ATTRIBUTE_NOTES,
ArtistMember::ATTRIBUTE_RELEVANCE,
];
/**
* Get the attributes that should be cast.
*
+2
View File
@@ -83,6 +83,8 @@ class AppServiceProvider extends ServiceProvider
{
Model::automaticallyEagerLoadRelationships();
Model::unguard();
Model::preventLazyLoading();
Model::handleLazyLoadingViolationUsing(function (Model $model, string $relation): void {