Files
leonm 8b60283eeb
CI / 🧪 Tests Laravel (push) Successful in 2m34s
CI / 🐳 Build & Push Images (push) Successful in 2m26s
feat: translation codes
2026-08-14 12:46:29 +02:00

39 lines
1022 B
PHP

<?php
namespace App\Http\Resources;
use App\Models\MealPosts;
use App\Models\PostReviews;
use App\Models\Report;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin Report */
class ReportResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'reason' => $this->reason,
'details' => $this->details,
'status' => $this->status,
'reportableType' => $this->reportableType(),
'reportableId' => $this->reportable_id,
'moderationCaseId' => $this->moderation_case_id,
'createdAt' => $this->created_at,
];
}
private function reportableType(): string
{
return match ($this->reportable_type) {
MealPosts::class => 'meal_post',
PostReviews::class => 'post_review',
User::class => 'user',
default => 'unknown',
};
}
}