initial commit
This commit is contained in:
commit
ae93c7e1a6
233 changed files with 20282 additions and 0 deletions
35
backend/app/Http/Resources/ProductResource.php
Normal file
35
backend/app/Http/Resources/ProductResource.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @property \App\Models\Product $resource
|
||||
*/
|
||||
class ProductResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->resource->id,
|
||||
'name' => $this->resource->name,
|
||||
'slug' => $this->resource->slug,
|
||||
'sku' => $this->resource->sku,
|
||||
'short_description' => $this->resource->short_description,
|
||||
'description' => $this->resource->description,
|
||||
'price' => $this->resource->price,
|
||||
'stock_quantity' => $this->resource->stock_quantity,
|
||||
'active' => $this->resource->active,
|
||||
'published_at' => $this->resource->published_at,
|
||||
'category' => CategoryResource::make($this->whenLoaded('category')),
|
||||
'brand' => BrandResource::make($this->whenLoaded('brand')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue