Issue #4645 fixed and product videos added in product api

This commit is contained in:
rahul shukla 2021-02-19 15:43:21 +05:30
parent e581c950df
commit ea66157655
2 changed files with 27 additions and 1 deletions

View File

@ -17,6 +17,8 @@ class Product extends JsonResource
$this->productReviewHelper = app('Webkul\Product\Helpers\Review'); $this->productReviewHelper = app('Webkul\Product\Helpers\Review');
$this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist'); $this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist');
parent::__construct($resource);
} }
/** /**
@ -45,7 +47,8 @@ class Product extends JsonResource
'formated_price' => core()->currency($productTypeInstance->getMinimalPrice()), 'formated_price' => core()->currency($productTypeInstance->getMinimalPrice()),
'short_description' => $product->short_description, 'short_description' => $product->short_description,
'description' => $product->description, 'description' => $product->description,
'images' => ProductImageFacade::collection($product->images), 'images' => ProductImage::collection($product->images),
'videos' => ProductVideo::collection($product->videos),
'base_image' => ProductImageFacade::getProductBaseImage($product), 'base_image' => ProductImageFacade::getProductBaseImage($product),
'created_at' => $product->created_at, 'created_at' => $product->created_at,
'updated_at' => $product->updated_at, 'updated_at' => $product->updated_at,

View File

@ -0,0 +1,23 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductVideo extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'type' => $this->type,
'url' => $this->url
];
}
}