25 خطوط
716 B
PHP
25 خطوط
716 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CommentResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'body' => $this->body,
|
|
'user_id' => $this->user_id,
|
|
'user' => new UserResource($this->whenLoaded('user')),
|
|
'commentable_id' => $this->commentable_id,
|
|
'commentable_type' => $this->commentable_type,
|
|
'files' => FileResource::collection($this->whenLoaded('files')),
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
];
|
|
}
|
|
}
|