feat: moderation
This commit is contained in:
@@ -13,8 +13,11 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -50,6 +53,9 @@ class User extends Authenticatable implements FilamentUser, HasLocalePreference,
|
||||
'pace_preference',
|
||||
'sex',
|
||||
'date_of_birth',
|
||||
'suspended_at',
|
||||
'suspended_by',
|
||||
'suspended_reason',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -83,6 +89,7 @@ class User extends Authenticatable implements FilamentUser, HasLocalePreference,
|
||||
'sex' => UserSex::class,
|
||||
'role' => UserRole::class,
|
||||
'date_of_birth' => 'immutable_date',
|
||||
'suspended_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -106,6 +113,41 @@ class User extends Authenticatable implements FilamentUser, HasLocalePreference,
|
||||
return $this->hasOne(StravaConnection::class);
|
||||
}
|
||||
|
||||
public function reportsMade(): HasMany
|
||||
{
|
||||
return $this->hasMany(Report::class, 'reporter_id');
|
||||
}
|
||||
|
||||
public function receivedReports(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Report::class, 'reportable');
|
||||
}
|
||||
|
||||
public function moderationCase(): MorphOne
|
||||
{
|
||||
return $this->morphOne(ModerationCase::class, 'caseable');
|
||||
}
|
||||
|
||||
public function assignedModerationCases(): HasMany
|
||||
{
|
||||
return $this->hasMany(ModerationCase::class, 'assigned_to');
|
||||
}
|
||||
|
||||
public function resolvedModerationCases(): HasMany
|
||||
{
|
||||
return $this->hasMany(ModerationCase::class, 'resolved_by');
|
||||
}
|
||||
|
||||
public function suspendedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'suspended_by');
|
||||
}
|
||||
|
||||
public function isSuspended(): bool
|
||||
{
|
||||
return $this->suspended_at !== null;
|
||||
}
|
||||
|
||||
public function routeNotificationForExpoPush(): array
|
||||
{
|
||||
return $this->deviceTokens()
|
||||
|
||||
Reference in New Issue
Block a user