mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 13:21:21 +03:30
fix some problems
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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,
|
||||
'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' => PackageResource::make($this->whenLoaded('package')),
|
||||
'transfers' => TransferResource::collection($this->whenLoaded('transfers')),
|
||||
'files' => MediaResource::collection($this->media),
|
||||
'thumbnail' => $this->getFirstMediaUrl('main_images', 'thumbnail'),
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user