product video facade added
This commit is contained in:
parent
7157318d18
commit
b57bcdc39e
|
|
@ -340,6 +340,7 @@ return [
|
|||
'Concord' => Konekt\Concord\Facades\Concord::class,
|
||||
'Helper' => Konekt\Concord\Facades\Helper::class,
|
||||
'Debugbar' => Barryvdh\Debugbar\Facade::class,
|
||||
'ProductImage' => Webkul\Product\Facades\ProductImage::class
|
||||
'ProductImage' => Webkul\Product\Facades\ProductImage::class,
|
||||
'ProductVideo' => Webkul\Product\Facades\ProductVideo::class
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class ProductVideo extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'productvideo';
|
||||
}
|
||||
}
|
||||
|
|
@ -28,11 +28,6 @@ class ProductImage extends AbstractProduct
|
|||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
public function sampleText()
|
||||
{
|
||||
echo "Sample Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve collection of gallery images
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Product\Helpers\AbstractProduct;
|
||||
|
||||
class ProductVideo extends AbstractProduct
|
||||
{
|
||||
/**
|
||||
* Retrieve collection of videos
|
||||
*
|
||||
* @param \Webkul\Product\Contracts\Product|\Webkul\Product\Contracts\ProductFlat $product
|
||||
* @return array
|
||||
*/
|
||||
public function getVideos($product)
|
||||
{
|
||||
if (! $product) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$videos = [];
|
||||
|
||||
foreach ($product->videos as $video) {
|
||||
if (! Storage::has($video->path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$videos[] = [
|
||||
'type' => $video->type,
|
||||
'video_url' => Storage::url($video->path),
|
||||
];
|
||||
}
|
||||
|
||||
return $videos;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,9 @@ use Webkul\Product\Console\Commands\PriceUpdate;
|
|||
use Webkul\Product\Console\Commands\GenerateProducts;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Webkul\Product\Facades\ProductImage as ProductImageFacade;
|
||||
use Webkul\Product\Facades\ProductVideo as ProductVideoFacade;
|
||||
use Webkul\Product\ProductImage;
|
||||
use Webkul\Product\ProductVideo;
|
||||
|
||||
class ProductServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -93,12 +95,21 @@ class ProductServiceProvider extends ServiceProvider
|
|||
*/
|
||||
protected function registerFacades()
|
||||
{
|
||||
// Product image
|
||||
$loader = AliasLoader::getInstance();
|
||||
$loader->alias('productimage', ProductImageFacade::class);
|
||||
|
||||
$this->app->singleton('productimage', function () {
|
||||
return app()->make(ProductImage::class);
|
||||
});
|
||||
|
||||
// Product video
|
||||
$loader = AliasLoader::getInstance();
|
||||
$loader->alias('productvideo', ProductVideoFacade::class);
|
||||
|
||||
$this->app->singleton('productvideo', function () {
|
||||
return app()->make(ProductVideo::class);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue