Files
muninn/app/Http/Resources/IdeaResource.php
T

37 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class IdeaResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'status' => $this->status,
'priority' => $this->priority,
'category' => $this->category,
'tags' => $this->tags,
'tags_array' => $this->tags_array,
'project_id' => $this->project_id,
'user_id' => $this->user_id,
'project' => $this->whenLoaded('project', fn () => [
'id' => $this->project->id,
'name' => $this->project->name,
]),
'user' => $this->whenLoaded('user', fn () => [
'id' => $this->user->id,
'name' => $this->user->name,
]),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
'deleted_at' => $this->deleted_at?->toIso8601String(),
];
}
}