wip
This commit is contained in:
30
app/Http/Resources/Api/V1/Vendor/Order/VendorOrderIndexResource.php
vendored
Normal file
30
app/Http/Resources/Api/V1/Vendor/Order/VendorOrderIndexResource.php
vendored
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Resources/Api/V1/Vendor/Order/VendorOrderShowResource.php
vendored
Normal file
39
app/Http/Resources/Api/V1/Vendor/Order/VendorOrderShowResource.php
vendored
Normal 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'),
|
||||
],
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
68
app/Http/Resources/Api/V1/Vendor/Product/VendorProductIndexResource.php
vendored
Normal file
68
app/Http/Resources/Api/V1/Vendor/Product/VendorProductIndexResource.php
vendored
Normal 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')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user