feat: moderation
This commit is contained in:
@@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MealPosts extends Model
|
||||
@@ -31,6 +33,9 @@ class MealPosts extends Model
|
||||
'type',
|
||||
'ai_generated',
|
||||
'diet_type',
|
||||
'hidden_at',
|
||||
'hidden_by',
|
||||
'hidden_reason',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
@@ -60,6 +65,26 @@ class MealPosts extends Model
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function reports(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Report::class, 'reportable');
|
||||
}
|
||||
|
||||
public function moderationCase(): MorphOne
|
||||
{
|
||||
return $this->morphOne(ModerationCase::class, 'caseable');
|
||||
}
|
||||
|
||||
public function hiddenBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'hidden_by');
|
||||
}
|
||||
|
||||
public function isHidden(): bool
|
||||
{
|
||||
return $this->hidden_at !== null;
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -68,6 +93,7 @@ class MealPosts extends Model
|
||||
'type' => MealPostType::class,
|
||||
'diet_type' => DietType::class,
|
||||
'ai_generated' => 'boolean',
|
||||
'hidden_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user