GET mastertasks, GET mastertasks/{id} endpointy

This commit is contained in:
StudioTem committed 2023-01-24 23:19:12 +01:00
1 parent dfac41f30a
commit ba6b9e20a5
16 files changed
+210 -12

No files matched your search

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class AttachmentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'content_type' => $this->content_type,
'disk_name' => $this->disk_name,
'extension' => $this->estimated_time,
'name' => $this->original_name,
'file_size' => $this->file_size,
'path' => $this->path,
];
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class MasterTaskCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'data' => $this->collection,
'status' => 200,
];
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class MasterTaskResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->title,
'description' => $this->description,
'duration' => $this->estimated_time,
'time_worked' => $this->tracked_time,
'is_finished' => $this->is_finished,
'starts_at' => $this->created_at,
'deadline' => $this->deadline,
'project_code' => $this->project->code,
'team_id' => $this->team->id,
'employees' => UserResource::collection($this->usersOutsideTeam),
'subtasks' => SubTaskResource::collection($this->subtasks),
'files' => AttachmentResource::collection($this->attachments),
];
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class SubTaskResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'description' => $this->mastertask->description,
'project_code' => $this->mastertask->project->code,
'master_task_id' => $this->mastertask->id,
'master_task' => $this->mastertask->title,
'team_id' => $this->mastertask->team->id,
'team' => $this->mastertask->team,
'employee_id' => $this->user->id,
'duration' => $this->estimated_time,
'spent_time' => $this->tracked_time,
'is_finished' => $this->is_finished,
'timeblocks' => TimeblockResource::collection($this->timeblocks),
];
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TimeblockResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'start' => $this->start,
'end' => $this->end,
];
}
}