diff --git a/packages/Webkul/Velocity/src/Config/admin-menu.php b/packages/Webkul/Velocity/src/Config/admin-menu.php index a41c96bfd..34f0060ac 100644 --- a/packages/Webkul/Velocity/src/Config/admin-menu.php +++ b/packages/Webkul/Velocity/src/Config/admin-menu.php @@ -2,22 +2,22 @@ return [ [ - 'key' => 'velocity', - 'name' => 'velocity::app.admin.layouts.velocity', - 'route' => 'velocity.admin.content.index', - 'sort' => 5, - 'icon-class' => 'velocity-icon', + 'key' => 'velocity', + 'name' => 'velocity::app.admin.layouts.velocity', + 'route' => 'velocity.admin.content.index', + 'sort' => 5, + 'icon-class' => 'velocity-icon' ], [ - 'key' => 'velocity.meta-data', - 'name' => 'velocity::app.admin.layouts.meta-data', - 'route' => 'velocity.admin.meta-data', - 'sort' => 1, - 'icon-class' => '', + 'key' => 'velocity.meta-data', + 'name' => 'velocity::app.admin.layouts.meta-data', + 'route' => 'velocity.admin.meta-data', + 'sort' => 1, + 'icon-class' => '' ], [ - 'key' => 'velocity.header', - 'name' => 'velocity::app.admin.layouts.header-content', - 'route' => 'velocity.admin.content.index', - 'sort' => 2, - 'icon-class' => '', + 'key' => 'velocity.header', + 'name' => 'velocity::app.admin.layouts.header-content', + 'route' => 'velocity.admin.content.index', + 'sort' => 2, + 'icon-class' => '' ], ]; \ No newline at end of file diff --git a/packages/Webkul/Velocity/src/Config/system.php b/packages/Webkul/Velocity/src/Config/system.php index 185a9cf96..8946c3340 100644 --- a/packages/Webkul/Velocity/src/Config/system.php +++ b/packages/Webkul/Velocity/src/Config/system.php @@ -2,22 +2,22 @@ return [ [ - 'key' => 'velocity', + 'key' => 'velocity', 'name' => 'velocity::app.admin.system.velocity.extension_name', 'sort' => 2 ], [ - 'key' => 'velocity.configuration', + 'key' => 'velocity.configuration', 'name' => 'velocity::app.admin.system.velocity.settings', 'sort' => 1, ], [ - 'key' => 'velocity.configuration.general', - 'name' => 'velocity::app.admin.system.velocity.general', - 'sort' => 1, + 'key' => 'velocity.configuration.general', + 'name' => 'velocity::app.admin.system.velocity.general', + 'sort' => 1, 'fields' => [ [ - 'name' => 'status', - 'title' => 'velocity::app.admin.system.general.status', - 'type' => 'select', + 'name' => 'status', + 'title' => 'velocity::app.admin.system.general.status', + 'type' => 'select', 'options' => [ [ 'title' => 'velocity::app.admin.system.general.active', @@ -30,14 +30,14 @@ return [ ] ] ], [ - 'key' => 'velocity.configuration.category', - 'name' => 'velocity::app.admin.system.velocity.category', - 'sort' => 1, + 'key' => 'velocity.configuration.category', + 'name' => 'velocity::app.admin.system.velocity.category', + 'sort' => 1, 'fields' => [ [ - 'name' => 'icon_status', - 'title' => 'velocity::app.admin.system.category.icon-status', - 'type' => 'select', + 'name' => 'icon_status', + 'title' => 'velocity::app.admin.system.category.icon-status', + 'type' => 'select', 'options' => [ [ 'title' => 'velocity::app.admin.system.category.active', @@ -48,9 +48,9 @@ return [ ] ] ], [ - 'name' => 'image_status', - 'title' => 'velocity::app.admin.system.category.image-status', - 'type' => 'select', + 'name' => 'image_status', + 'title' => 'velocity::app.admin.system.category.image-status', + 'type' => 'select', 'options' => [ [ 'title' => 'velocity::app.admin.system.category.active', @@ -61,29 +61,29 @@ return [ ] ] ], [ - 'name' => 'image_height', - 'title' => 'velocity::app.admin.system.category.image-height', - 'type' => 'depands', - 'depand' => 'image_status:true', - 'validation' => 'numeric|max:3', + 'name' => 'image_height', + 'title' => 'velocity::app.admin.system.category.image-height', + 'type' => 'depands', + 'depand' => 'image_status:true', + 'validation' => 'numeric|max:3', 'channel_based' => false, - 'locale_based' => false, + 'locale_based' => false, ], [ - 'name' => 'image_width', - 'title' => 'velocity::app.admin.system.category.image-width', - 'type' => 'depands', - 'depand' => 'image_status:true', - 'validation' => 'numeric|max:3', + 'name' => 'image_width', + 'title' => 'velocity::app.admin.system.category.image-width', + 'type' => 'depands', + 'depand' => 'image_status:true', + 'validation' => 'numeric|max:3', 'channel_based' => false, - 'locale_based' => false, + 'locale_based' => false, ], [ - 'name' => 'image_alignment', - 'title' => 'velocity::app.admin.system.category.image-alignment', + 'name' => 'image_alignment', + 'title' => 'velocity::app.admin.system.category.image-alignment', 'channel_based' => false, - 'locale_based' => false, - 'type' => 'depands', - 'depand' => 'image_status:true', - 'options' => [ + 'locale_based' => false, + 'type' => 'depands', + 'depand' => 'image_status:true', + 'options' => [ [ 'title' => 'Right', 'value' => 'right' @@ -93,9 +93,9 @@ return [ ] ] ], [ - 'name' => 'tooltip_status', - 'title' => 'velocity::app.admin.system.category.show-tooltip', - 'type' => 'select', + 'name' => 'tooltip_status', + 'title' => 'velocity::app.admin.system.category.show-tooltip', + 'type' => 'select', 'options' => [ [ 'title' => 'velocity::app.admin.system.category.active', @@ -106,12 +106,12 @@ return [ ] ] ], [ - 'name' => 'sub_category', - 'title' => 'velocity::app.admin.system.category.sub-category-show', + 'name' => 'sub_category', + 'title' => 'velocity::app.admin.system.category.sub-category-show', 'channel_based' => false, - 'locale_based' => false, - 'type' => 'select', - 'options' => [ + 'locale_based' => false, + 'type' => 'select', + 'options' => [ [ 'title' => 'All', 'value' => 'all' @@ -121,13 +121,13 @@ return [ ] ] ], [ - 'name' => 'sub_category_num', - 'title' => 'velocity::app.admin.system.category.num-sub-category', + 'name' => 'sub_category_num', + 'title' => 'velocity::app.admin.system.category.num-sub-category', 'channel_based' => false, - 'locale_based' => false, - 'type' => 'depands', - 'depand' => 'sub_category:custom', - 'validation' => 'numeric|max:2', + 'locale_based' => false, + 'type' => 'depands', + 'depand' => 'sub_category:custom', + 'validation' => 'numeric|max:2', ] ] ] diff --git a/packages/Webkul/Velocity/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Velocity/src/DataGrids/CategoryDataGrid.php index c7f990133..de25d6a77 100644 --- a/packages/Webkul/Velocity/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Velocity/src/DataGrids/CategoryDataGrid.php @@ -13,9 +13,9 @@ use DB; */ class CategoryDataGrid extends DataGrid { - protected $index = 'category_menu_id'; //the column that needs to be treated as index column + protected $index = 'category_menu_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -39,45 +39,45 @@ class CategoryDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'category_id', - 'label' => trans('velocity::app.admin.category.datagrid.category-id'), - 'type' => 'number', + 'index' => 'category_id', + 'label' => trans('velocity::app.admin.category.datagrid.category-id'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('velocity::app.admin.category.datagrid.category-name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('velocity::app.admin.category.datagrid.category-name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'icon', - 'label' => trans('velocity::app.admin.category.datagrid.category-icon'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'icon', + 'label' => trans('velocity::app.admin.category.datagrid.category-icon'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, 'filterable' => true, - 'closure' => true, - 'wrapper' => function ($row) { + 'closure' => true, + 'wrapper' => function ($row) { return ''; } ]); $this->addColumn([ - 'index' => 'status', - 'label' => trans('velocity::app.admin.category.datagrid.category-status'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'status', + 'label' => trans('velocity::app.admin.category.datagrid.category-status'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, 'filterable' => true, - 'closure' => true, - 'wrapper' => function($row) { + 'closure' => true, + 'wrapper' => function($row) { if ( $row->status ) { return 'Enabled'; } else { @@ -89,27 +89,27 @@ class CategoryDataGrid extends DataGrid public function prepareActions() { $this->addAction([ - 'type' => 'Edit', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'velocity.admin.category.edit', - 'icon' => 'icon pencil-lg-icon' + 'type' => 'Edit', + 'method' => 'GET', + 'route' => 'velocity.admin.category.edit', + 'icon' => 'icon pencil-lg-icon' ]); $this->addAction([ - 'type' => 'Delete', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'velocity.admin.category.delete', + 'type' => 'Delete', + 'method' => 'POST', + 'route' => 'velocity.admin.category.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Category']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon' ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', + 'type' => 'delete', 'action' => route('velocity.admin.category.mass-delete'), - 'label' => trans('admin::app.datagrid.delete'), + 'label' => trans('admin::app.datagrid.delete'), 'method' => 'DELETE' ]); } diff --git a/packages/Webkul/Velocity/src/DataGrids/ContentDataGrid.php b/packages/Webkul/Velocity/src/DataGrids/ContentDataGrid.php index 793d4e24a..0d6ce496d 100644 --- a/packages/Webkul/Velocity/src/DataGrids/ContentDataGrid.php +++ b/packages/Webkul/Velocity/src/DataGrids/ContentDataGrid.php @@ -35,90 +35,92 @@ class ContentDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'content_id', - 'label' => trans('velocity::app.admin.contents.datagrid.id'), - 'type' => 'number', + 'index' => 'content_id', + 'label' => trans('velocity::app.admin.contents.datagrid.id'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'title', - 'label' => trans('velocity::app.admin.contents.datagrid.title'), - 'type' => 'string', + 'index' => 'title', + 'label' => trans('velocity::app.admin.contents.datagrid.title'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'position', - 'label' => trans('velocity::app.admin.contents.datagrid.position'), - 'type' => 'number', + 'index' => 'position', + 'label' => trans('velocity::app.admin.contents.datagrid.position'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'status', - 'label' => trans('velocity::app.admin.contents.datagrid.status'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'status', + 'label' => trans('velocity::app.admin.contents.datagrid.status'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) + 'wrapper' => function($value) { + if ($value->status == 1) { return 'Active'; - else + } else { return 'Inactive'; + } } ]); $this->addColumn([ - 'index' => 'content_type', - 'label' => trans('velocity::app.admin.contents.datagrid.content-type'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'content_type', + 'label' => trans('velocity::app.admin.contents.datagrid.content-type'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->content_type == 'category') + 'wrapper' => function($value) { + if ($value->content_type == 'category') { return 'Category Slug'; - else if ($value->content_type == 'link') + } else if ($value->content_type == 'link') { return 'Link'; - else if ($value->content_type == 'product') + } else if ($value->content_type == 'product') { return 'Product'; - else if ($value->content_type == 'static') + } else if ($value->content_type == 'static') { return 'Static'; + } } ]); } public function prepareActions() { $this->addAction([ - 'type' => 'Edit', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'velocity.admin.content.edit', - 'icon' => 'icon pencil-lg-icon' + 'type' => 'Edit', + 'method' => 'GET', + 'route' => 'velocity.admin.content.edit', + 'icon' => 'icon pencil-lg-icon' ]); $this->addAction([ - 'type' => 'Delete', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'velocity.admin.content.delete', + 'type' => 'Delete', + 'method' => 'POST', + 'route' => 'velocity.admin.content.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'content']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon' ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', + 'type' => 'delete', 'action' => route('velocity.admin.content.mass-delete'), - 'label' => trans('admin::app.datagrid.delete'), + 'label' => trans('admin::app.datagrid.delete'), 'method' => 'DELETE' ]); } diff --git a/packages/Webkul/Velocity/src/Database/Seeders/VelocityMetaDataSeeder.php b/packages/Webkul/Velocity/src/Database/Seeders/VelocityMetaDataSeeder.php index 7dd12f603..1a3b32817 100644 --- a/packages/Webkul/Velocity/src/Database/Seeders/VelocityMetaDataSeeder.php +++ b/packages/Webkul/Velocity/src/Database/Seeders/VelocityMetaDataSeeder.php @@ -14,17 +14,15 @@ class VelocityMetaDataSeeder extends Seeder DB::table('velocity_meta_data')->insert([ 'id' => 1, - 'home_page_content' => "

@include('shop::home.advertisements.advertisement-four')@include('shop::home.featured-products') @include('shop::home.product-policy') @include('shop::home.advertisements.advertisement-three') @include('shop::home.new-products') @include('shop::home.advertisements.advertisement-two')

", + 'home_page_content' => "

@include('shop::home.advertisements.advertisement-four')@include('shop::home.featured-products') @include('shop::home.product-policy') @include('shop::home.advertisements.advertisement-three') @include('shop::home.new-products') @include('shop::home.advertisements.advertisement-two')

", + 'footer_left_content' => trans('velocity::app.admin.meta-data.footer-left-raw-content'), - 'footer_left_content' => trans('velocity::app.admin.meta-data.footer-left-raw-content'), - - 'footer_middle_content' => '
', - - 'slider' => 1, + 'footer_middle_content' => '
', + 'slider' => 1, 'subscription_bar_content' => '
', - 'product_policy' => '
Free Shipping on Order $20 or More
Product Replace & Return Available
Product Exchange and EMI Available
', + 'product_policy' => '
Free Shipping on Order $20 or More
Product Replace & Return Available
Product Exchange and EMI Available
', ]); } } diff --git a/packages/Webkul/Velocity/src/Helpers/AdminHelper.php b/packages/Webkul/Velocity/src/Helpers/AdminHelper.php index 9d464b5eb..c97cdaa68 100644 --- a/packages/Webkul/Velocity/src/Helpers/AdminHelper.php +++ b/packages/Webkul/Velocity/src/Helpers/AdminHelper.php @@ -14,9 +14,8 @@ class AdminHelper */ protected $categoryRepository; - public function __construct( - CategoryRepository $categoryRepository - ) { + public function __construct(CategoryRepository $categoryRepository) + { $this->categoryRepository = $categoryRepository; } @@ -33,12 +32,12 @@ class AdminHelper public function storeCategoryIcon($category) { $data = request()->all(); - $type = 'category_icon_path'; - if (! $category instanceof \Webkul\Category\Models\Category) + if (! $category instanceof \Webkul\Category\Contracts\Category) { $category = $this->categoryRepository->findOrFail($category); + } - $category = $this->uploadImage($category, $data, $type); + $category = $this->uploadImage($category, $data, 'category_icon_path'); return $category; } diff --git a/packages/Webkul/Velocity/src/Helpers/Helper.php b/packages/Webkul/Velocity/src/Helpers/Helper.php index dbaafbb5e..946394679 100644 --- a/packages/Webkul/Velocity/src/Helpers/Helper.php +++ b/packages/Webkul/Velocity/src/Helpers/Helper.php @@ -58,16 +58,21 @@ class Helper extends Review public function __construct( ProductModel $productModel, ProductRepository $productRepository, - AttributeOptionRepository $attributeOption, + AttributeOptionRepository $attributeOptionRepository, OrderBrandsRepository $orderBrandsRepository, ProductReviewRepository $productReviewRepository, VelocityMetadataRepository $velocityMetadataRepository ) { $this->productModel = $productModel; - $this->attributeOption = $attributeOption; + + $this->attributeOptionRepository = $attributeOptionRepository; + $this->productRepository = $productRepository; + $this->orderBrandsRepository = $orderBrandsRepository; + $this->productReviewRepository = $productReviewRepository; + $this->velocityMetadataRepository = $velocityMetadataRepository; } @@ -79,15 +84,14 @@ class Helper extends Review $products[] = $orderItem->product; $this->orderBrandsRepository->create([ - 'order_id' => $orderItem->order_id, + 'order_id' => $orderItem->order_id, 'order_item_id' => $orderItem->id, - 'product_id' => $orderItem->product_id, - 'brand' => $products[$key]->brand, + 'product_id' => $orderItem->product_id, + 'brand' => $products[$key]->brand, ]); } } - public function getBrandsWithCategories() { try { @@ -101,8 +105,9 @@ class Helper extends Review } $categoryName = $brandName = $brandImplode = []; + foreach($product_categories as $totalData) { - $brand = $this->attributeOption->findOneWhere(['id' => $totalData['brand']]); + $brand = $this->attributeOptionRepository->findOneWhere(['id' => $totalData['brand']]); foreach ($totalData['categories'] as $categories) { foreach($categories['translations'] as $catName) { @@ -213,11 +218,11 @@ class Helper extends Review $images = $product->getTypeInstance()->getBaseImage($item); return [ - 'images' => $images, - 'itemId' => $item->id, - 'name' => $item->name, - 'url_key' => $product->url_key, - 'quantity' => $item->quantity, + 'images' => $images, + 'itemId' => $item->id, + 'name' => $item->name, + 'url_key' => $product->url_key, + 'quantity' => $item->quantity, 'baseTotal' => core()->currency($item->base_total), ]; } diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Admin/CategoryController.php b/packages/Webkul/Velocity/src/Http/Controllers/Admin/CategoryController.php index 8f9ad1b76..2c69987ef 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Admin/CategoryController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Admin/CategoryController.php @@ -3,8 +3,8 @@ namespace Webkul\Velocity\Http\Controllers\Admin; use Illuminate\Http\Response; -use Webkul\Category\Repositories\CategoryRepository as Category; -use Webkul\Velocity\Repositories\CategoryRepository as VelocityCategory; +use Webkul\Category\Repositories\CategoryRepository; +use Webkul\Velocity\Repositories\CategoryRepository as VelocityCategoryRepository; /** * Category Controller @@ -31,18 +31,18 @@ class CategoryController extends Controller /** * Create a new controller instance. * - * @param \Webkul\Category\Repositories\CategoryRepository $category; + * @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository; * @param \Webkul\Velocity\Repositories\CategoryRepository $velocityCategory; * @return void */ public function __construct( - Category $category, - VelocityCategory $velocityCategory + CategoryRepository $categoryRepository, + VelocityCategoryRepository $velocityCategoryRepository ) { - $this->category = $category; + $this->categoryRepository = $categoryRepository; - $this->velocityCategory = $velocityCategory; + $this->velocityCategoryRepository = $velocityCategoryRepository; $this->_config = request('_config'); } @@ -53,11 +53,12 @@ class CategoryController extends Controller */ public function index() { - if (!core()->getConfigData('velocity.configuration.general.status')) { + if (! core()->getConfigData('velocity.configuration.general.status')) { session()->flash('error', trans('velocity::app.admin.system.velocity.error-module-inactive')); return redirect()->route('admin.configuration.index', ['slug' => 'velocity', 'slug2' => 'configuration']); } + return view($this->_config['view']); } @@ -68,7 +69,7 @@ class CategoryController extends Controller */ public function create() { - $categories = $this->velocityCategory->getChannelCategories(); + $categories = $this->velocityCategoryRepository->getChannelCategories(); return view($this->_config['view'], compact('categories')); } @@ -80,7 +81,7 @@ class CategoryController extends Controller */ public function store() { - $this->velocityCategory->create(request()->all()); + $this->velocityCategoryRepository->create(request()->all()); session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Category Menu'])); @@ -95,9 +96,9 @@ class CategoryController extends Controller */ public function edit($id) { - $categories = $this->category->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id); + $categories = $this->categoryRepository->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id); - $velocityCategory = $this->velocityCategory->findOrFail($id); + $velocityCategory = $this->velocityCategoryRepository->findOrFail($id); return view($this->_config['view'], compact('categories', 'velocityCategory')); } @@ -110,7 +111,7 @@ class CategoryController extends Controller */ public function update($id) { - $velocityCategory = $this->velocityCategory->update(request()->all(), $id); + $velocityCategory = $this->velocityCategoryRepository->update(request()->all(), $id); session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category Menu'])); @@ -125,10 +126,10 @@ class CategoryController extends Controller */ public function destroy($id) { - $velocityCategory = $this->velocityCategory->findOrFail($id); + $velocityCategory = $this->velocityCategoryRepository->findOrFail($id); try { - $this->velocityCategory->delete($id); + $this->velocityCategoryRepository->delete($id); session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category Menu'])); @@ -150,11 +151,10 @@ class CategoryController extends Controller $menuIds = explode(',', request()->input('indexes')); foreach ($menuIds as $menuId) { - - $velocityCategory = $this->velocityCategory->find($menuId); + $velocityCategory = $this->velocityCategoryRepository->find($menuId); if (isset($velocityCategory)) { - $this->velocityCategory->delete($menuId); + $this->velocityCategoryRepository->delete($menuId); } } diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ConfigurationController.php b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ConfigurationController.php index 4f98ac4aa..ed3561f32 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ConfigurationController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ConfigurationController.php @@ -43,7 +43,7 @@ class ConfigurationController extends Controller { $velocityMetaData = $this->velocityHelper->getVelocityMetaData(); - if ( $velocityMetaData->advertisement ) { + if ($velocityMetaData->advertisement) { $velocityMetaData->advertisement = $this->manageAddImages(json_decode($velocityMetaData->advertisement, true)); } @@ -71,12 +71,12 @@ class ConfigurationController extends Controller $params['advertisement'] = []; - if ( isset($params['images'])) { + if (isset($params['images'])) { foreach ($params['images'] as $index => $images) { $params['advertisement'][$index] = $this->uploadAdvertisementImages($images, $index, $advertisement); } - if ( $advertisement ) { + if ($advertisement) { foreach ($advertisement as $key => $image_array) { if (! isset($params['images'][$key])) { foreach ($advertisement[$key] as $image) { @@ -120,7 +120,7 @@ class ConfigurationController extends Controller $file = 'images.' . $index . '.' . $imageId; $dir = 'velocity/images'; - if ( Str::contains($imageId, 'image_') ) { + if (Str::contains($imageId, 'image_')) { if (request()->hasFile($file) && $image) { $filter_index = substr($imageId, 6, 1); if ( isset($data[$filter_index]) ) { @@ -146,7 +146,7 @@ class ConfigurationController extends Controller } } - if ( isset($advertisement[$index]) && $advertisement[$index]) { + if (isset($advertisement[$index]) && $advertisement[$index]) { foreach ($advertisement[$index] as $imageId) { Storage::delete($imageId); } @@ -178,12 +178,12 @@ class ConfigurationController extends Controller $images_path = []; foreach ($add_images as $add_id => $images) { foreach ($images as $key => $image) { - if ( $image ) { + if ($image) { $images_path[$add_id][] = [ - 'id' => $key, + 'id' => $key, 'type' => null, 'path' => $image, - 'url' => Storage::url($image) + 'url' => Storage::url($image) ]; } } diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php index 7aec5d4f7..2ae92b3fe 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php @@ -27,22 +27,22 @@ class ContentController extends Controller * * @var object */ - protected $content; + protected $contentRepository; /** * Create a new controller instance. * - * @param \Webkul\Product\Repositories\ProductRepository $productRepository; - * @param \Webkul\Velocity\Repositories\ContentRepository $content; + * @param \Webkul\Product\Repositories\ProductRepository $productRepository + * @param \Webkul\Velocity\Repositories\ContentRepository $contentRepository * @return void */ public function __construct( ProductRepository $productRepository, - ContentRepository $content + ContentRepository $contentRepository ) { $this->productRepository = $productRepository; - $this->content = $content; + $this->contentRepository = $contentRepository; $this->_config = request('_config'); } @@ -67,10 +67,10 @@ class ContentController extends Controller $params = request()->input(); - if ( isset($params['query']) && $params['query'] ) { + if (isset($params['query']) && $params['query']) { foreach ($this->productRepository->searchProductByAttribute(request()->input('query')) as $row) { $results[] = [ - 'id' => $row->product_id, + 'id' => $row->product_id, 'name' => $row->name, ]; } @@ -97,11 +97,11 @@ class ContentController extends Controller { $params = request()->all(); - if ( isset($params['products']) ) { + if (isset($params['products'])) { $params['products'] = json_encode($params['products']); } - $this->content->create($params); + $this->contentRepository->create($params); session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Content Page'])); @@ -116,7 +116,7 @@ class ContentController extends Controller */ public function edit($id) { - $content = $this->content->findOrFail($id); + $content = $this->contentRepository->findOrFail($id); return view($this->_config['view'], compact('content')); } @@ -132,11 +132,11 @@ class ContentController extends Controller { $params = request()->all(); - if ( isset($params['locale']) && isset($params[$params['locale']]['products']) ) { + if (isset($params['locale']) && isset($params[$params['locale']]['products'])) { $params[$params['locale']]['products'] = json_encode($params[$params['locale']]['products']); } - $content = $this->content->update($params, $id); + $content = $this->contentRepository->update($params, $id); session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Content'])); @@ -151,10 +151,10 @@ class ContentController extends Controller */ public function destroy($id) { - $content = $this->content->findOrFail($id); + $content = $this->contentRepository->findOrFail($id); try { - $this->content->delete($id); + $this->contentRepository->delete($id); session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Content'])); @@ -177,10 +177,10 @@ class ContentController extends Controller foreach ($contentIds as $contentId) { - $content = $this->content->find($contentId); + $content = $this->contentRepository->find($contentId); if (isset($content)) { - $this->content->delete($contentId); + $this->contentRepository->delete($contentId); } } diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php index 47253f770..51d690a0f 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php @@ -59,7 +59,9 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep $this->_config = request('_config'); $this->searchRepository = $searchRepository; + $this->productRepository = $productRepository; + $this->velocityProductRepository = $velocityProductRepository; } @@ -81,24 +83,26 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep if ($product) { $productReviewHelper = app('Webkul\Product\Helpers\Review'); + $productImageHelper = app('Webkul\Product\Helpers\ProductImage'); + $galleryImages = $productImageHelper->getProductBaseImage($product); $response = [ - 'status' => true, + 'status' => true, 'details' => [ - 'name' => $product->name, - 'urlKey' => $product->url_key, - 'priceHTML' => $product->getTypeInstance()->getPriceHtml(), + 'name' => $product->name, + 'urlKey' => $product->url_key, + 'priceHTML' => $product->getTypeInstance()->getPriceHtml(), 'totalReviews' => $productReviewHelper->getTotalReviews($product), - 'rating' => ceil($productReviewHelper->getAverageRating($product)), - 'image' => $galleryImages['small_image_url'], + 'rating' => ceil($productReviewHelper->getAverageRating($product)), + 'image' => $galleryImages['small_image_url'], ] ]; } else { $response = [ 'status' => false, - 'slug' => $slug, + 'slug' => $slug, ]; } @@ -149,10 +153,10 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep } $response = [ - 'status' => true, - 'list' => $list, - 'categoryDetails' => $categoryDetails, - 'categoryProducts' => $customizedProducts, + 'status' => true, + 'list' => $list, + 'categoryDetails' => $categoryDetails, + 'categoryProducts' => $customizedProducts ]; } @@ -174,7 +178,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep } return [ - 'status' => true, + 'status' => true, 'categories' => $formattedCategories, ]; } @@ -185,7 +189,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep if ($categoryDetails) { $response = [ - 'status' => true, + 'status' => true, 'categoryDetails' => $this->getCategoryFilteredData($categoryDetails) ]; } @@ -203,10 +207,10 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep } return [ - 'id' => $category->id, - 'slug' => $category->slug, - 'name' => $category->name, - 'children' => $formattedChildCategory, + 'id' => $category->id, + 'slug' => $category->slug, + 'name' => $category->name, + 'children' => $formattedChildCategory, 'category_icon_path' => $category->category_icon_path, ]; } @@ -224,19 +228,19 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep $productImage = $productImageHelper->getProductBaseImage($product)['medium_image_url']; return [ - 'name' => $product->name, - 'slug' => $product->url_key, - 'image' => $productImage, - 'description' => $product->description, + 'name' => $product->name, + 'slug' => $product->url_key, + 'image' => $productImage, + 'description' => $product->description, 'shortDescription' => $product->meta_description, - 'galleryImages' => $galleryImages, - 'priceHTML' => view('shop::products.price', ['product' => $product])->render(), - 'totalReviews' => $totalReviews, - 'avgRating' => $avgRatings, - 'firstReviewText' => trans('velocity::app.products.be-first-review'), - 'addToCartHtml' => view('shop::products.add-to-cart', [ - 'product' => $product, - 'addWishlistClass' => !(isset($list) && $list) ? '' : '', + 'galleryImages' => $galleryImages, + 'priceHTML' => view('shop::products.price', ['product' => $product])->render(), + 'totalReviews' => $totalReviews, + 'avgRating' => $avgRatings, + 'firstReviewText' => trans('velocity::app.products.be-first-review'), + 'addToCartHtml' => view('shop::products.add-to-cart', [ + 'product' => $product, + 'addWishlistClass' => !(isset($list) && $list) ? '' : '', 'addToCartBtnClass' => !(isset($list) && $list) ? $addToCartBtnClass ?? '' : '' ])->render(), ]; @@ -267,7 +271,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep if (is_array($cart) && isset($cart['warning'])) { $response = [ - 'status' => 'warning', + 'status' => 'warning', 'message' => $cart['warning'], ]; } @@ -281,30 +285,32 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep } $response = [ - 'status' => 'success', + 'status' => 'success', 'totalCartItems' => sizeof($items), - 'addedItems' => array_slice($formattedItems, sizeof($formattedBeforeItems)), - 'message' => trans('shop::app.checkout.cart.item.success'), + 'addedItems' => array_slice($formattedItems, sizeof($formattedBeforeItems)), + 'message' => trans('shop::app.checkout.cart.item.success'), ]; - if ($customer = auth()->guard('customer')->user()) + if ($customer = auth()->guard('customer')->user()) { $this->wishlistRepository->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]); + } - if (request()->get('is_buy_now')) + if (request()->get('is_buy_now')) { return redirect()->route('shop.checkout.onepage.index'); + } } } catch(\Exception $exception) { $product = $this->productRepository->find($id); $response = [ - 'status' => 'false', - 'message' => trans($exception->getMessage()), + 'status' => 'false', + 'message' => trans($exception->getMessage()), 'redirectionRoute' => route('shop.productOrCategory.index', $product->url_key), ]; } return $response ?? [ - 'status' => 'error', + 'status' => 'error', 'message' => trans('velocity::app.error.something-went-wrong'), ]; } diff --git a/packages/Webkul/Velocity/src/Providers/VelocityServiceProvider.php b/packages/Webkul/Velocity/src/Providers/VelocityServiceProvider.php index 0ae5f3556..a9f9c2b21 100644 --- a/packages/Webkul/Velocity/src/Providers/VelocityServiceProvider.php +++ b/packages/Webkul/Velocity/src/Providers/VelocityServiceProvider.php @@ -28,15 +28,21 @@ class VelocityServiceProvider extends ServiceProvider public function boot(Router $router) { include __DIR__ . '/../Http/helpers.php'; + include __DIR__ . '/../Http/admin-routes.php'; + include __DIR__ . '/../Http/front-routes.php'; $this->app->register(EventServiceProvider::class); $this->loadGloableVariables(); + $this->loadPublishableAssets(); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'velocity'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'velocity'); } @@ -48,6 +54,7 @@ class VelocityServiceProvider extends ServiceProvider public function register() { $this->registerConfig(); + $this->registerFacades(); } @@ -75,6 +82,7 @@ class VelocityServiceProvider extends ServiceProvider protected function registerFacades() { $loader = AliasLoader::getInstance(); + $loader->alias('velocity', VelocityFacade::class); } diff --git a/packages/Webkul/Velocity/src/Repositories/CategoryRepository.php b/packages/Webkul/Velocity/src/Repositories/CategoryRepository.php index 8cd327d12..8f6292400 100644 --- a/packages/Webkul/Velocity/src/Repositories/CategoryRepository.php +++ b/packages/Webkul/Velocity/src/Repositories/CategoryRepository.php @@ -57,12 +57,12 @@ class CategoryRepository extends Repository $categories = $this->category->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id); - if ( isset($categories->first()->id)) { + if (isset($categories->first()->id)) { foreach ($categories as $category) { - if ( !empty($categoryMenues) && !in_array($category->id, array_column($categoryMenues, 'category_id'))) { + if (! empty($categoryMenues) && !in_array($category->id, array_column($categoryMenues, 'category_id'))) { $results[] = [ - 'id' => $category->id, + 'id' => $category->id, 'name' => $category->name, ]; } diff --git a/packages/Webkul/Velocity/src/Repositories/ContentRepository.php b/packages/Webkul/Velocity/src/Repositories/ContentRepository.php index ddf84e0b6..92124f764 100644 --- a/packages/Webkul/Velocity/src/Repositories/ContentRepository.php +++ b/packages/Webkul/Velocity/src/Repositories/ContentRepository.php @@ -101,13 +101,13 @@ class ContentRepository extends Repository $products = json_decode($contentLocale->products, true); - if (!empty($products)) { + if (! empty($products)) { foreach ($products as $product_id) { $product = $this->productRepository->find($product_id); - if ( isset($product->id)) { + if (isset($product->id)) { $results[] = [ - 'id' => $product->id, + 'id' => $product->id, 'name' => $product->name, ]; } @@ -132,11 +132,12 @@ class ContentRepository extends Repository ->get(); $formattedContent = []; + foreach ($contentCollection as $content) { array_push($formattedContent, [ - 'title' => $content->title, - 'page_link' => $content->page_link, - 'link_target' => $content->link_target, + 'title' => $content->title, + 'page_link' => $content->page_link, + 'link_target' => $content->link_target, 'content_type' => $content->content_type, ]); } diff --git a/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php b/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php index e9e033834..956aa87d8 100644 --- a/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php +++ b/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php @@ -118,7 +118,7 @@ class ProductRepository extends Repository ->where('product_flat.locale', $locale) ->whereNotNull('product_flat.url_key'); - if ( $term ) + if ($term) $query->where('product_flat.name', 'like', '%' . urldecode($term) . '%'); if ($categoryId && $categoryId !== "") { diff --git a/packages/Webkul/Velocity/src/Velocity.php b/packages/Webkul/Velocity/src/Velocity.php index c625fef00..b51b9738c 100644 --- a/packages/Webkul/Velocity/src/Velocity.php +++ b/packages/Webkul/Velocity/src/Velocity.php @@ -2,7 +2,7 @@ namespace Webkul\Velocity; -use Webkul\Category\Repositories\CategoryRepository as Category; +use Webkul\Category\Repositories\CategoryRepository; class Velocity { @@ -12,9 +12,9 @@ class Velocity * @var mixed */ protected $content_type = [ - // 'link' => 'Link CMS Page', - // 'product' => 'Catalog Products', - // 'static' => 'Static Content', + // 'link' => 'Link CMS Page', + // 'product' => 'Catalog Products', + // 'static' => 'Static Content', 'category' => 'Category Slug', ]; @@ -24,33 +24,34 @@ class Velocity * @var mixed */ protected $catalog_type = [ - 'new' => 'New Arrival', - 'offer' => 'Offered Product [Special]', + 'new' => 'New Arrival', + 'offer' => 'Offered Product [Special]', 'popular' => 'Popular Products', - 'viewed' => 'Most Viewed', - 'rated' => 'Most Rated', - 'custom' => 'Custom Selection', + 'viewed' => 'Most Viewed', + 'rated' => 'Most Rated', + 'custom' => 'Custom Selection', ]; - protected $category; + protected $categoryRepository; /** * Create a new instance. * - * @param Webkul\Category\Repositories\CategoryRepository $category + * @param Webkul\Category\Repositories\CategoryRepository $categoryRepository * @return void */ - public function __construct( - Category $category - ) { - $this->category = $category; + public function __construct(CategoryRepository $categoryRepository) + { + $this->categoryRepository = $categoryRepository; } - public function getContentType() { + public function getContentType() + { return $this->content_type; } - public function getCatalogType() { + public function getCatalogType() + { return $this->catalog_type; } } \ No newline at end of file