This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\Api\V1\Cart;
use App\Http\Controllers\Api\V1\Product\Resources\ProductResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class CartResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'product_id' => $this->product_id,
'product_quantity' => $this->product_quantity,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'product' => new ProductResource($this->whenLoaded('product')),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\Api\V1\Channel;
use App\Http\Resources\Api\V1\Channel\Resources\ChannelMediaResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ChannelResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->whenHas('id'),
'sort_order' => $this->whenHas('sort_order'),
'name' => $this->whenHas('name'),
'slug' => $this->whenHas('slug'),
'description' => $this->whenHas('description'),
'media' => ChannelMediaResource::collection($this->whenLoaded('media')),
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources\Api\V1\Channel\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ChannelMediaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'thumbnail' => $this->getUrl(),
'images_400x400' => $this->getUrl('thumb400x400'),
'images_720x720' => $this->getUrl('thumb720x720'),
'images_800x800' => $this->getUrl('thumb800x800'),
'images_1200x1200' => $this->getUrl('thumb1200x1200'),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\Api\V1\Common;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class CommentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'comment' => $this->comment,
'user' => [
'id' => $this->user->id,
'name' => $this->user->fullname,
],
'created_at' => $this->created_at,
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources\Api\V1\Legal;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class LegalPageResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'slug' => $this->slug,
'title' => $this->title,
'content' => $this->content,
];
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Resources\Api\V1\Order;
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
use App\Models\Ecommerce\Product\Order\Status\OrderStatus;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderIndexResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'status' => OrderStatus::formattedStatusFor($this->status),
'shipping_method' => OrderShipping::formattedShippingMethod($this->shipping_method),
'notes' => $this->notes,
'customer_name' => $this->customer_name,
'customer_phone' => $this->customer_phone,
'customer_address' => $this->customer_address,
'delivery_time' => $this->delivery_time,
'delivery_at' => $this->delivery_at,
'region' => $this->region,
'user_id' => $this->user_id,
'province_id' => $this->province_id,
'payment_type' => $this->paymentType?->name,
'orderItems' => OrderItemResource::collection($this->whenLoaded('items')),
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources\Api\V1\Order;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'product' => [
'id' => $this->product_id,
'name' => $this->product->name,
'thumbnail' => $this->product->thumbnail(),
'images_400x400' => $this->product->getFirstMediaUrl('uploads', 'thumb400x400'),
'images_800x800' => $this->product->getFirstMediaUrl('uploads', 'thumb800x800'),
'images_1200x1200' => $this->product->getFirstMediaUrl('uploads', 'thumb1200x1200'),
],
'order' => [
'id' => $this->order_id,
],
'quantity' => $this->quantity,
'unit_price_amount' => $this->unit_price_amount,
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources\Api\V1\Vendor\Order;
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
use App\Models\Ecommerce\Product\Order\Status\OrderStatus;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class VendorOrderIndexResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'status' => OrderStatus::formattedStatusFor($this->status),
'shipping_method' => OrderShipping::formattedShippingMethod($this->shipping_method),
'notes' => $this->notes,
'delivery_time' => $this->delivery_time,
'delivery_at' => $this->delivery_at?->format('d.m.Y'),
'region' => $this->region,
'payment_type' => $this->paymentType?->name,
];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Resources\Api\V1\Vendor\Order;
use App\Models\Ecommerce\Product\Order\Shipping\OrderShipping;
use App\Models\Ecommerce\Product\Order\Status\OrderStatus;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class VendorOrderShowResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'status' => OrderStatus::formattedStatusFor($this->status),
'shipping_method' => OrderShipping::formattedShippingMethod($this->shipping_method),
'notes' => $this->notes,
'delivery_time' => $this->delivery_time,
'delivery_at' => $this->delivery_at,
'region' => $this->region,
'payment_type' => $this->paymentType?->name,
'products' => $this->items->map(fn ($item) => [
'quantity' => $item->quantity,
'product' => [
'id' => $item->product->id,
'name' => $item->product->name,
'price_amount' => $item->product->price_amount,
'thumbnail' => $item->product->thumbnail('thumb150x150'),
],
]),
];
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Http\Resources\Api\V1\Vendor\Product;
use App\Http\Controllers\Api\V1\Product\Resources\Attribute\ProductAttributeProductShowResource;
use App\Http\Controllers\Api\V1\Product\Resources\ProductMediaResource;
use App\Http\Controllers\Api\V1\Product\Resources\Variant\ProductVariantResource;
use App\Http\Resources\Api\V1\Channel\ChannelResource;
use App\Repositories\Ecommerce\Product\Property\PropertyRepository;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class VendorProductIndexResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$media = $this->whenLoaded('media');
return [
'id' => $this->id,
'parent_id' => $this->parent_id,
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
'sku' => $this->sku,
'barcode' => $this->barcode,
'stock' => $this->stock,
'price_amount' => $this->price_amount,
'old_price_amount' => $this->old_price_amount,
'backorder' => boolval($this->backorder),
'weight_value' => $this->weight_value,
'weight_unit' => $this->weight_unit,
'height_value' => $this->height_value,
'height_unit' => $this->height_unit,
'media' => ProductMediaResource::collection($media),
'created_at' => $this->created_at,
'seo_title' => $this->seo_title,
'seo_description' => $this->seo_description,
'is_visible' => $this->is_visible,
'colour' => PropertyRepository::getRealValue('colour', $this->colour),
'size' => PropertyRepository::getRealValue('size', $this->size),
'brand' => [
'id' => $this->brand_id,
'name' => $this->brand?->name,
],
'channel' => ChannelResource::collection($this->whenLoaded('channels')),
'properties' => ProductAttributeProductShowResource::collection($this->whenLoaded('properties')),
'variations' => ProductVariantResource::collection($this->whenLoaded('variations')),
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class MediaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'thumbnail' => $this->getUrl('thumb720x720'),
'images_400x400' => $this->getUrl('thumb400x400'),
'images_720x720' => $this->getUrl('thumb720x720'),
'images_800x800' => $this->getUrl('thumb800x800'),
'images_1200x1200' => $this->getUrl('thumb1200x1200'),
];
}
}