mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-08 22:03:16 +01:00
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.
44 lines
1.3 KiB
PHP
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),
|
|
];
|
|
}
|
|
}
|