refactor: replace $fillable with $guarded = [] across all models

Aligns all models with the project convention (see .ai/rules/models.md).
Model::shouldBeStrict() in non-production will catch any issues early.
pull/6872/head
Your Name 4 weeks ago
parent c891f34df6
commit 570a30d037

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class AccountLog extends Model
{
protected $fillable = ['*'];
protected $guarded = [];
public function user()
{

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class Activity extends Model
{
protected $fillable = ['data', 'to_id', 'from_id', 'object_type'];
protected $guarded = [];
protected function casts(): array
{

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class Bookmark extends Model
{
protected $fillable = ['profile_id', 'status_id'];
protected $guarded = [];
public function status()
{

@ -6,14 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class Circle extends Model
{
protected $fillable = [
'profile_id',
'name',
'description',
'bcc',
'scope',
'active',
];
protected $guarded = [];
public function members()
{

@ -6,8 +6,5 @@ use Illuminate\Database\Eloquent\Model;
class CircleProfile extends Model
{
protected $fillable = [
'circle_id',
'profile_id',
];
protected $guarded = [];
}

@ -3,18 +3,19 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property string $slug
* @property int|null $media_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Media|null $media
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Media|null $media
*/
class DiscoverCategory extends Model
{
protected $fillable = ['slug'];
protected $guarded = [];
public function media()
{

@ -6,8 +6,5 @@ use Illuminate\Database\Eloquent\Model;
class DiscoverCategoryHashtag extends Model
{
protected $fillable = [
'discover_category_id',
'hashtag_id',
];
protected $guarded = [];
}

@ -3,23 +3,24 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property int $follower_id
* @property int $following_id
* @property array|null $activity
* @property \Illuminate\Support\Carbon|null $handled_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Profile $target
* @property-read \App\Profile $actor
* @property-read \App\Profile $follower
* @property-read \App\Profile $following
* @property Carbon|null $handled_at
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Profile $target
* @property-read Profile $actor
* @property-read Profile $follower
* @property-read Profile $following
*/
class FollowRequest extends Model
{
protected $fillable = ['follower_id', 'following_id', 'activity', 'handled_at'];
protected $guarded = [];
protected function casts(): array
{

@ -3,21 +3,22 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property int $profile_id
* @property int $following_id
* @property bool|null $local_profile
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Profile $actor
* @property-read \App\Profile $target
* @property-read \App\Profile $profile
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Profile $actor
* @property-read Profile $target
* @property-read Profile $profile
*/
class Follower extends Model
{
protected $fillable = ['profile_id', 'following_id', 'local_profile'];
protected $guarded = [];
const MAX_FOLLOWING = 7500;

@ -7,11 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class HashtagFollow extends Model
{
protected $fillable = [
'user_id',
'profile_id',
'hashtag_id',
];
protected $guarded = [];
const MAX_LIMIT = 25;

@ -6,13 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class Instance extends Model
{
protected $fillable = [
'domain',
'banned',
'auto_cw',
'unlisted',
'notes',
];
protected $guarded = [];
protected function casts(): array
{

@ -8,7 +8,7 @@ class ModLog extends Model
{
protected $visible = ['id'];
protected $fillable = ['*'];
protected $guarded = [];
public function admin()
{

@ -7,16 +7,7 @@ use Illuminate\Support\Str;
class AdminInvite extends Model
{
protected $fillable = [
'name',
'description',
'message',
'max_uses',
'uses',
'skip_email_verification',
'expires_at',
'admin_user_id',
];
protected $guarded = [];
protected function casts(): array
{

@ -9,5 +9,5 @@ class Conversation extends Model
{
use HasFactory;
protected $fillable = ['from_id', 'to_id'];
protected $guarded = [];
}

@ -9,9 +9,7 @@ class CuratedRegisterTemplate extends Model
{
use HasFactory;
protected $fillable = [
'name', 'description', 'content', 'is_active', 'order',
];
protected $guarded = [];
protected function casts(): array
{

@ -7,9 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CustomFilterKeyword extends Model
{
protected $fillable = [
'keyword', 'whole_word', 'custom_filter_id',
];
protected $guarded = [];
protected function casts(): array
{

@ -7,9 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class CustomFilterStatus extends Model
{
protected $fillable = [
'custom_filter_id', 'status_id',
];
protected $guarded = [];
public function customFilter()
{

@ -9,10 +9,7 @@ class GroupLimit extends Model
{
use HasFactory;
protected $fillable = [
'profile_id',
'group_id',
];
protected $guarded = [];
protected function casts(): array
{

@ -19,15 +19,7 @@ class GroupPost extends Model
*/
public $incrementing = false;
protected $fillable = [
'remote_url',
'group_id',
'profile_id',
'type',
'caption',
'visibility',
'is_nsfw',
];
protected $guarded = [];
public function mediaPath()
{

@ -12,10 +12,7 @@ class UserOidcMapping extends Model
public $timestamps = true;
protected $fillable = [
'user_id',
'oidc_id',
];
protected $guarded = [];
public function user()
{

@ -8,7 +8,7 @@ class Newsroom extends Model
{
protected $table = 'newsroom';
protected $fillable = ['title'];
protected $guarded = [];
protected function casts(): array
{

@ -11,7 +11,7 @@ class Page extends Model
'page',
];
protected $fillable = ['slug'];
protected $guarded = [];
public function url()
{

@ -9,9 +9,5 @@ class StatusView extends Model
{
use HasFactory;
protected $fillable = [
'status_id',
'status_profile_id',
'profile_id',
];
protected $guarded = [];
}

@ -34,7 +34,7 @@ class Story extends Model
*/
public $incrementing = false;
protected $fillable = ['profile_id', 'view_count'];
protected $guarded = [];
protected $visible = ['id'];

@ -8,12 +8,7 @@ class UIKit extends Model
{
protected $table = 'uikit';
protected $fillable = [
'k',
'v',
'defv',
'dhis',
];
protected $guarded = [];
public static function section($k)
{

@ -2,16 +2,12 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Services\UserAgentService;
use Illuminate\Database\Eloquent\Model;
class UserDevice extends Model
{
protected $fillable = [
'user_id',
'ip',
'user_agent',
];
protected $guarded = [];
public $timestamps = [
'last_active_at',

@ -6,17 +6,12 @@ use Illuminate\Database\Eloquent\Model;
class UserFilter extends Model
{
protected $fillable = [
'user_id',
'filterable_id',
'filterable_type',
'filter_type',
];
protected $guarded = [];
public function mutedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType(\App\Profile::class)
->whereFilterableType(Profile::class)
->whereFilterType('mute')
->pluck('filterable_id');
}
@ -24,7 +19,7 @@ class UserFilter extends Model
public function blockedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType(\App\Profile::class)
->whereFilterableType(Profile::class)
->whereFilterType('block')
->pluck('filterable_id');
}

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class UserSetting extends Model
{
protected $fillable = ['user_id'];
protected $guarded = [];
protected function casts(): array
{

Loading…
Cancel
Save