Added Item model, resource and its API.

Updated Category model to have Items.
This commit is contained in:
2023-06-14 17:16:50 +03:00
parent b5a264d92f
commit 18bd849827
12 changed files with 350 additions and 0 deletions
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Resources\API\v2;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ItemCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @return array<int|string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\API\v2;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'uuid' => $this->uuid,
'name' => $this->name,
'url' => $this->url,
'description' => $this->description,
'price' => $this->price,
'image' => $this->image,
];
}
}