feat: report reviews etc ...

This commit is contained in:
2026-05-23 12:15:11 +02:00
parent 49419c1e7b
commit 4af28f3828
15 changed files with 146 additions and 0 deletions
+5
View File
@@ -52,6 +52,7 @@ class ModerationCase extends Model
{
return match ($this->caseable_type) {
MealPosts::class => 'meal_post',
PostReviews::class => 'post_review',
User::class => 'user',
default => 'unknown',
};
@@ -61,6 +62,7 @@ class ModerationCase extends Model
{
return match ($this->caseable_type) {
MealPosts::class => __('admin.moderation_cases.targets.meal_post'),
PostReviews::class => __('admin.moderation_cases.targets.post_review'),
User::class => __('admin.moderation_cases.targets.user'),
default => __('admin.moderation_cases.targets.unknown'),
};
@@ -72,6 +74,9 @@ class ModerationCase extends Model
return match (true) {
$target instanceof MealPosts => $target->title,
$target instanceof PostReviews => filled($target->comment)
? str($target->comment)->limit(80)->toString()
: __('admin.moderation_cases.targets.post_review'),
$target instanceof User => $target->name,
default => (string) $this->caseable_id,
};
+12
View File
@@ -5,6 +5,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
class PostReviews extends Model
{
@@ -27,6 +29,16 @@ class PostReviews extends Model
return $this->belongsTo(User::class);
}
public function reports(): MorphMany
{
return $this->morphMany(Report::class, 'reportable');
}
public function moderationCase(): MorphOne
{
return $this->morphOne(ModerationCase::class, 'caseable');
}
protected function casts(): array
{
return [