feat: moderation
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\MealPosts;
|
||||
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,
|
||||
'reasonLabel' => $this->reason?->getLabel(),
|
||||
'details' => $this->details,
|
||||
'status' => $this->status,
|
||||
'statusLabel' => $this->status?->getLabel(),
|
||||
'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',
|
||||
User::class => 'user',
|
||||
default => 'unknown',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user