33 lines
778 B
PHP
33 lines
778 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Task;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/**
|
|
* @mixin Task
|
|
*/
|
|
class TaskResource extends JsonResource
|
|
{
|
|
|
|
/**
|
|
* Transform the resource collection into an array.
|
|
*
|
|
* @return array<int|string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'description' => $this->description,
|
|
'status' => $this->status->value,
|
|
'due_date' => $this->due_date?->toDateString(),
|
|
'created_at' => $this->created_at?->toDateTimeString(),
|
|
'updated_at' => $this->updated_at?->toDateTimeString(),
|
|
];
|
|
}
|
|
}
|