Files
solidtime/app/Http/Resources/V1/Task/TaskResource.php
Constantin Graf 7a3a9d7089 Fix Scramble API docs warnings
Remove redundant @var annotations from API resources and defer the user
access in the email unique rule of UserUpdateRequest, so rules() can be
evaluated by Scramble without route model binding. Add a test that fails
on any Scramble diagnostic and tests for the email unique rule.
2026-10-08 12:57:56 +02:00

44 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\V1\Task;
use App\Http\Resources\V1\BaseResource;
use App\Models\Tag;
use App\Models\Task;
use Illuminate\Http\Request;
/**
* @property Task $resource
*/
class TaskResource extends BaseResource
{
/**
* Transform the resource into an array.
*
* @return array<string, string|bool|int|null>
*/
public function toArray(Request $request): array
{
return [
/** ID */
'id' => $this->resource->id,
/** Name */
'name' => $this->resource->name,
/** Whether the task is done */
'is_done' => $this->resource->is_done,
/** ID of the project */
'project_id' => $this->resource->project_id,
/** Estimated time in seconds */
'estimated_time' => $this->resource->estimated_time,
/** Spent time on this task in seconds (sum of the duration of all associated time entries, excl. still running time entries) */
'spent_time' => $this->resource->spent_time,
/** When the tag was created */
'created_at' => $this->formatDateTime($this->resource->created_at),
/** When the tag was last updated */
'updated_at' => $this->formatDateTime($this->resource->updated_at),
];
}
}