pull/6483/head
Your Name 5 days ago
parent 72fcc173de
commit 2f06f30508

@ -6,18 +6,16 @@ use Illuminate\Database\Eloquent\Model;
class AccountInterstitial extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'read_at' => 'datetime',
'appeal_requested_at' => 'datetime',
];
public const JSON_MESSAGE = 'Please use web browser to proceed.';
protected function casts(): array
{
return [
'read_at' => 'datetime',
'appeal_requested_at' => 'datetime',
];
}
public function user()
{
return $this->belongsTo(User::class);

@ -6,12 +6,15 @@ use Illuminate\Database\Eloquent\Model;
class Activity extends Model
{
protected $casts = [
'processed_at' => 'datetime',
];
protected $fillable = ['data', 'to_id', 'from_id', 'object_type'];
protected function casts(): array
{
return [
'processed_at' => 'datetime',
];
}
public function toProfile()
{
return $this->belongsTo(Profile::class, 'to_id');

@ -9,19 +9,17 @@ class Avatar extends Model
{
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
'last_fetched_at' => 'datetime',
'last_processed_at' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
'last_fetched_at' => 'datetime',
'last_processed_at' => 'datetime',
];
}
protected $visible = [
'id',
'profile_id',

@ -7,9 +7,12 @@ use Illuminate\Support\Str;
class Contact extends Model
{
protected $casts = [
'responded_at' => 'datetime',
];
protected function casts(): array
{
return [
'responded_at' => 'datetime',
];
}
public function user()
{

@ -21,9 +21,12 @@ class FollowRequest extends Model
{
protected $fillable = ['follower_id', 'following_id', 'activity', 'handled_at'];
protected $casts = [
'activity' => 'array',
];
protected function casts(): array
{
return [
'activity' => 'array',
];
}
public function actor()
{

@ -6,14 +6,6 @@ use Illuminate\Database\Eloquent\Model;
class Instance extends Model
{
protected $casts = [
'last_crawled_at' => 'datetime',
'actors_last_synced_at' => 'datetime',
'notes' => 'array',
'nodeinfo_last_fetched' => 'datetime',
'delivery_next_after' => 'datetime',
];
protected $fillable = [
'domain',
'banned',
@ -22,6 +14,17 @@ class Instance extends Model
'notes',
];
protected function casts(): array
{
return [
'last_crawled_at' => 'datetime',
'actors_last_synced_at' => 'datetime',
'notes' => 'array',
'nodeinfo_last_fetched' => 'datetime',
'delivery_next_after' => 'datetime',
];
}
// To get all moderated instances, we need to search where (banned OR unlisted)
public function scopeModerated($query): void
{

@ -11,17 +11,15 @@ class Like extends Model
const MAX_PER_DAY = 1500;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
];
protected $fillable = ['profile_id', 'status_id', 'status_profile_id'];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
];
}
public function actor()
{
return $this->belongsTo(Profile::class, 'profile_id', 'id');

@ -12,18 +12,16 @@ class Media extends Model
{
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $guarded = [];
protected $casts = [
'srcset' => 'array',
'deleted_at' => 'datetime',
'skip_optimize' => 'boolean',
];
protected function casts(): array
{
return [
'srcset' => 'array',
'deleted_at' => 'datetime',
'skip_optimize' => 'boolean',
];
}
public function status()
{

@ -9,17 +9,15 @@ class Mention extends Model
{
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
];
}
public function profile()
{
return $this->belongsTo(Profile::class, 'profile_id', 'id');

@ -7,11 +7,6 @@ use Illuminate\Support\Str;
class AdminInvite extends Model
{
protected $casts = [
'used_by' => 'array',
'expires_at' => 'datetime',
];
protected $fillable = [
'name',
'description',
@ -23,6 +18,14 @@ class AdminInvite extends Model
'admin_user_id',
];
protected function casts(): array
{
return [
'used_by' => 'array',
'expires_at' => 'datetime',
];
}
protected static function booted(): void
{
static::creating(function (AdminInvite $invite) {

@ -13,9 +13,12 @@ class AdminShadowFilter extends Model
protected $guarded = [];
protected $casts = [
'created_at' => 'datetime',
];
protected function casts(): array
{
return [
'created_at' => 'datetime',
];
}
public function account()
{

@ -13,18 +13,21 @@ class CuratedRegister extends Model
'user_has_responded',
];
protected $casts = [
'autofollow_account_ids' => 'array',
'admin_notes' => 'array',
'email_verified_at' => 'datetime',
'admin_notified_at' => 'datetime',
'action_taken_at' => 'datetime',
'user_has_responded' => 'boolean',
'is_awaiting_more_info' => 'boolean',
'is_accepted' => 'boolean',
'is_rejected' => 'boolean',
'is_closed' => 'boolean',
];
protected function casts(): array
{
return [
'autofollow_account_ids' => 'array',
'admin_notes' => 'array',
'email_verified_at' => 'datetime',
'admin_notified_at' => 'datetime',
'action_taken_at' => 'datetime',
'user_has_responded' => 'boolean',
'is_awaiting_more_info' => 'boolean',
'is_accepted' => 'boolean',
'is_rejected' => 'boolean',
'is_closed' => 'boolean',
];
}
public function adminStatusLabel()
{

@ -11,11 +11,14 @@ class CuratedRegisterActivity extends Model
protected $guarded = [];
protected $casts = [
'metadata' => 'array',
'admin_notified_at' => 'datetime',
'action_taken_at' => 'datetime',
];
protected function casts(): array
{
return [
'metadata' => 'array',
'admin_notified_at' => 'datetime',
'action_taken_at' => 'datetime',
];
}
public function application()
{

@ -13,7 +13,10 @@ class CuratedRegisterTemplate extends Model
'name', 'description', 'content', 'is_active', 'order',
];
protected $casts = [
'is_active' => 'boolean',
];
protected function casts(): array
{
return [
'is_active' => 'boolean',
];
}
}

@ -14,15 +14,18 @@ class CustomFilter extends Model
'title', 'phrase', 'context', 'expires_at', 'action', 'profile_id',
];
protected $casts = [
'id' => 'string',
'context' => 'array',
'expires_at' => 'datetime',
'action' => 'integer',
];
protected $guarded = ['shouldInvalidateCache'];
protected function casts(): array
{
return [
'id' => 'string',
'context' => 'array',
'expires_at' => 'datetime',
'action' => 'integer',
];
}
const VALID_CONTEXTS = [
'home',
'notifications',

@ -10,9 +10,12 @@ class CustomFilterKeyword extends Model
'keyword', 'whole_word', 'custom_filter_id',
];
protected $casts = [
'whole_word' => 'boolean',
];
protected function casts(): array
{
return [
'whole_word' => 'boolean',
];
}
public function customFilter()
{

@ -33,9 +33,12 @@ class Group extends Model
*/
public $incrementing = false;
protected $casts = [
'metadata' => 'json',
];
protected function casts(): array
{
return [
'metadata' => 'json',
];
}
public function url()
{

@ -9,7 +9,10 @@ class GroupInteraction extends Model
{
use HasFactory;
protected $casts = [
'metadata' => 'array',
];
protected function casts(): array
{
return [
'metadata' => 'array',
];
}
}

@ -9,13 +9,16 @@ class GroupLimit extends Model
{
use HasFactory;
protected $casts = [
'limits' => 'json',
'metadata' => 'json',
];
protected $fillable = [
'profile_id',
'group_id',
];
protected function casts(): array
{
return [
'limits' => 'json',
'metadata' => 'json',
];
}
}

@ -11,14 +11,12 @@ class HashtagRelated extends Model
protected $guarded = [];
/**
* The attributes that should be mutated to dates and other custom formats.
*
* @var array
*/
protected $casts = [
'related_tags' => 'array',
'last_calculated_at' => 'datetime',
'last_moderated_at' => 'datetime',
];
protected function casts(): array
{
return [
'related_tags' => 'array',
'last_calculated_at' => 'datetime',
'last_moderated_at' => 'datetime',
];
}
}

@ -10,11 +10,14 @@ class ImportPost extends Model
{
use HasFactory;
protected $casts = [
'media' => 'array',
'creation_date' => 'datetime',
'metadata' => 'json',
];
protected function casts(): array
{
return [
'media' => 'array',
'creation_date' => 'datetime',
'metadata' => 'json',
];
}
public function status()
{

@ -26,14 +26,17 @@ class ParentalControls extends Model
{
use HasFactory, SoftDeletes;
protected $casts = [
'permissions' => 'array',
'email_sent_at' => 'datetime',
'email_verified_at' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'permissions' => 'array',
'email_sent_at' => 'datetime',
'email_verified_at' => 'datetime',
];
}
public function parent()
{
return $this->belongsTo(User::class, 'parent_id');

@ -17,11 +17,14 @@ class Poll extends Model
*/
public $incrementing = false;
protected $casts = [
'poll_options' => 'array',
'cached_tallies' => 'array',
'expires_at' => 'datetime',
];
protected function casts(): array
{
return [
'poll_options' => 'array',
'cached_tallies' => 'array',
'expires_at' => 'datetime',
];
}
public function votes()
{

@ -24,9 +24,12 @@ class Portfolio extends Model
'profile_source',
];
protected $casts = [
'metadata' => 'json',
];
protected function casts(): array
{
return [
'metadata' => 'json',
];
}
public function url($suffix = '')
{

@ -11,9 +11,12 @@ class RemoteAuth extends Model
protected $guarded = [];
protected $casts = [
'verify_credentials' => 'array',
'last_successful_login_at' => 'datetime',
'last_verify_credentials_at' => 'datetime',
];
protected function casts(): array
{
return [
'verify_credentials' => 'array',
'last_successful_login_at' => 'datetime',
'last_verify_credentials_at' => 'datetime',
];
}
}

@ -9,9 +9,12 @@ class RemoteReport extends Model
{
use HasFactory;
protected $casts = [
'status_ids' => 'array',
'action_taken_meta' => 'array',
'report_meta' => 'array',
];
protected function casts(): array
{
return [
'status_ids' => 'array',
'action_taken_meta' => 'array',
'report_meta' => 'array',
];
}
}

@ -9,11 +9,14 @@ class StatusEdit extends Model
{
use HasFactory;
protected $casts = [
'ordered_media_attachment_ids' => 'array',
'media_descriptions' => 'array',
'poll_options' => 'array',
];
protected $guarded = [];
protected function casts(): array
{
return [
'ordered_media_attachment_ids' => 'array',
'media_descriptions' => 'array',
'poll_options' => 'array',
];
}
}

@ -12,16 +12,19 @@ class UserAppSettings extends Model
protected $guarded = [];
protected $casts = [
'common' => 'json',
'custom' => 'json',
'common.timelines.show_public' => 'boolean',
'common.timelines.show_network' => 'boolean',
'common.timelines.hide_likes_shares' => 'boolean',
'common.media.hide_public_behind_cw' => 'boolean',
'common.media.always_show_cw' => 'boolean',
'common.media.show_alt_text' => 'boolean',
];
protected function casts(): array
{
return [
'common' => 'json',
'custom' => 'json',
'common.timelines.show_public' => 'boolean',
'common.timelines.show_network' => 'boolean',
'common.timelines.hide_likes_shares' => 'boolean',
'common.media.hide_public_behind_cw' => 'boolean',
'common.media.always_show_cw' => 'boolean',
'common.media.show_alt_text' => 'boolean',
];
}
public function user()
{

@ -11,7 +11,10 @@ class UserEmailForgot extends Model
protected $guarded = [];
protected $casts = [
'email_sent_at' => 'datetime',
];
protected function casts(): array
{
return [
'email_sent_at' => 'datetime',
];
}
}

@ -12,10 +12,13 @@ class UserRoles extends Model
protected $guarded = [];
protected $casts = [
'roles' => 'array',
'meta' => 'array',
];
protected function casts(): array
{
return [
'roles' => 'array',
'meta' => 'array',
];
}
public function user()
{

@ -10,9 +10,12 @@ class Newsroom extends Model
protected $fillable = ['title'];
protected $casts = [
'published_at' => 'datetime',
];
protected function casts(): array
{
return [
'published_at' => 'datetime',
];
}
public function permalink()
{

@ -9,17 +9,15 @@ class Notification extends Model
{
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
];
}
public function actor()
{
return $this->belongsTo(Profile::class, 'actor_id', 'id');

@ -41,18 +41,21 @@ class Profile extends Model
*/
public $incrementing = false;
protected $casts = [
'deleted_at' => 'datetime',
'last_fetched_at' => 'datetime',
'last_status_at' => 'datetime',
];
protected $hidden = ['private_key'];
protected $visible = ['id', 'user_id', 'username', 'name'];
protected $guarded = [];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
'last_fetched_at' => 'datetime',
'last_status_at' => 'datetime',
];
}
public function user()
{
return $this->belongsTo(User::class);

@ -6,12 +6,15 @@ use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
protected $casts = [
'admin_seen' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'admin_seen' => 'datetime',
];
}
public function url()
{
return url('/i/admin/reports/show/'.$this->id);

@ -51,18 +51,16 @@ class Status extends Model
*/
public $incrementing = false;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'deleted_at' => 'datetime',
'edited_at' => 'datetime',
];
protected $guarded = [];
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
'edited_at' => 'datetime',
];
}
const STATUS_TYPES = [
'text',
'photo',

@ -32,18 +32,21 @@ class Story extends Model
*/
public $incrementing = false;
protected $casts = [
'story' => 'json',
'expires_at' => 'datetime',
'view_count' => 'integer',
];
protected $fillable = ['profile_id', 'view_count'];
protected $visible = ['id'];
protected $hidden = ['json'];
protected function casts(): array
{
return [
'story' => 'json',
'expires_at' => 'datetime',
'view_count' => 'integer',
];
}
public function profile()
{
return $this->belongsTo(Profile::class);

@ -25,17 +25,15 @@ class StoryItem extends Model
*/
public $incrementing = false;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $casts = [
'expires_at' => 'datetime',
];
protected $visible = ['id'];
protected function casts(): array
{
return [
'expires_at' => 'datetime',
];
}
public function story()
{
return $this->belongsTo(Story::class);

@ -8,8 +8,11 @@ class UserSetting extends Model
{
protected $fillable = ['user_id'];
protected $casts = [
'compose_settings' => 'json',
'other' => 'json',
];
protected function casts(): array
{
return [
'compose_settings' => 'json',
'other' => 'json',
];
}
}

Loading…
Cancel
Save