mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 03:11:06 +03:30
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Services\Media\Resources\MediaResource;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ItemResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'udi' => $this->udi,
|
|
'size' => $this->size,
|
|
'specific' => $this->specific,
|
|
'note' => $this->note,
|
|
'repair' => $this->repair,
|
|
'status' => $this->status,
|
|
'creator_id' => $this->creator_id,
|
|
'creator' => UserResource::make($this->whenLoaded('creator')),
|
|
'user_id' => $this->user_id,
|
|
'user' => UserResource::make($this->whenLoaded('user')),
|
|
'package_id' => $this->package_id,
|
|
'package' => PackageResource::make($this->whenLoaded('package')),
|
|
'transfers' => TransferResource::collection($this->whenLoaded('transfers')),
|
|
'files' => MediaResource::collection($this->whenLoaded('media')),
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at
|
|
];
|
|
}
|
|
}
|