¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -2,6 +2,7 @@
namespace Themes\Storefront\Http\ViewComposers;
use Illuminate\View\View;
use Themes\Storefront\Banner;
use Themes\Storefront\Feature;
use Modules\Brand\Entities\Brand;
@@ -15,7 +16,8 @@ class HomePageComposer
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
* @param View $view
*
* @return void
*/
public function compose($view)
@@ -37,9 +39,10 @@ class HomePageComposer
]);
}
private function featuredCategoriesSection()
{
if (! setting('storefront_featured_categories_section_enabled')) {
if (!setting('storefront_featured_categories_section_enabled')) {
return;
}
@@ -50,10 +53,11 @@ class HomePageComposer
];
}
private function getFeaturedCategories()
{
$categoryIds = Collection::times(6, function ($number) {
if (! is_null(setting("storefront_featured_categories_section_category_{$number}_product_type"))) {
if (!is_null(setting("storefront_featured_categories_section_category_{$number}_product_type"))) {
return setting("storefront_featured_categories_section_category_{$number}_category_id");
}
})->filter();
@@ -72,6 +76,7 @@ class HomePageComposer
});
}
private function threeColumnFullWidthBanners()
{
if (setting('storefront_three_column_full_width_banners_enabled')) {
@@ -79,22 +84,24 @@ class HomePageComposer
}
}
private function productTabsOne()
{
if (! setting('storefront_product_tabs_1_section_enabled')) {
if (!setting('storefront_product_tabs_1_section_enabled')) {
return;
}
return Collection::times(4, function ($number) {
if (! is_null(setting("storefront_product_tabs_1_section_tab_{$number}_product_type"))) {
if (!is_null(setting("storefront_product_tabs_1_section_tab_{$number}_product_type"))) {
return setting("storefront_product_tabs_1_section_tab_{$number}_title");
}
})->filter();
}
private function topBrands()
{
if (! setting('storefront_top_brands_section_enabled')) {
if (!setting('storefront_top_brands_section_enabled')) {
return collect();
}
@@ -103,7 +110,7 @@ class HomePageComposer
return Cache::rememberForever(md5('storefront_top_brands:' . serialize($topBrandIds)), function () use ($topBrandIds) {
return Brand::with('files')
->whereIn('id', $topBrandIds)
->when(! empty($topBrandIds), function ($query) use ($topBrandIds) {
->when(!empty($topBrandIds), function ($query) use ($topBrandIds) {
$topBrandIdsString = collect($topBrandIds)->filter()->implode(',');
$query->orderByRaw("FIELD(id, {$topBrandIdsString})");
@@ -118,6 +125,7 @@ class HomePageComposer
});
}
private function flashSaleAndVerticalProducts()
{
return [
@@ -128,6 +136,7 @@ class HomePageComposer
];
}
private function twoColumnBanners()
{
if (setting('storefront_two_column_banners_enabled')) {
@@ -135,19 +144,21 @@ class HomePageComposer
}
}
private function productGrid()
{
if (! setting('storefront_product_grid_section_enabled')) {
if (!setting('storefront_product_grid_section_enabled')) {
return;
}
return Collection::times(4, function ($number) {
if (! is_null(setting("storefront_product_grid_section_tab_{$number}_product_type"))) {
if (!is_null(setting("storefront_product_grid_section_tab_{$number}_product_type"))) {
return setting("storefront_product_grid_section_tab_{$number}_title");
}
})->filter();
}
private function threeColumnBanners()
{
if (setting('storefront_three_column_banners_enabled')) {
@@ -155,14 +166,15 @@ class HomePageComposer
}
}
private function tabProductsTwo()
{
if (! setting('storefront_product_tabs_2_section_enabled')) {
if (!setting('storefront_product_tabs_2_section_enabled')) {
return;
}
$tabs = Collection::times(4, function ($number) {
if (! is_null(setting("storefront_product_tabs_2_section_tab_{$number}_product_type"))) {
if (!is_null(setting("storefront_product_tabs_2_section_tab_{$number}_product_type"))) {
return setting("storefront_product_tabs_2_section_tab_{$number}_title");
}
})->filter();
@@ -173,6 +185,7 @@ class HomePageComposer
];
}
private function oneColumnBanner()
{
if (setting('storefront_one_column_banner_enabled')) {

View File

@@ -2,6 +2,8 @@
namespace Themes\Storefront\Http\ViewComposers;
use Exception;
use Illuminate\View\View;
use Mexitek\PHPColors\Color;
use Modules\Compare\Compare;
use Spatie\SchemaOrg\Schema;
@@ -18,24 +20,27 @@ use Modules\Product\Entities\SearchTerm;
class LayoutComposer
{
/**
* @var \Modules\Compare\Compare
* @var Compare
*/
private $compare;
/**
* Create a new view composer instance.
*
* @param \Modules\Compare\Compare $compare
* @param Compare $compare
*/
public function __construct(Compare $compare)
{
$this->compare = $compare;
}
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
* @param View $view
*
* @return void
*/
public function compose($view)
@@ -63,29 +68,36 @@ class LayoutComposer
]);
}
public function footerTagsCallback($tagIds)
{
return function () use ($tagIds) {
return Tag::whereIn('id', $tagIds)
->when(!empty($tagIds), function ($query) use ($tagIds) {
$tagIdsString = collect($tagIds)->filter()->implode(',');
$query->orderByRaw("FIELD(id, {$tagIdsString})");
})
->get();
};
}
private function getThemeColor()
{
try {
return new Color(storefront_theme_color());
} catch (\Exception $e) {
} catch (Exception $e) {
return new Color('#0068e1');
}
}
private function getFavicon()
{
return $this->getMedia(setting('storefront_favicon'))->path;
}
private function getHeaderLogo()
{
return $this->getMedia(setting('storefront_header_logo'))->path;
}
private function getNewsletterBgImage()
{
return $this->getMedia(setting('storefront_newsletter_bg_image'))->path;
}
private function getMedia($fileId)
{
@@ -94,6 +106,19 @@ class LayoutComposer
});
}
private function getHeaderLogo()
{
return $this->getMedia(setting('storefront_header_logo'))->path;
}
private function getNewsletterBgImage()
{
return $this->getMedia(setting('storefront_newsletter_bg_image'))->path;
}
private function getPrivacyPageUrl()
{
return Cache::tags('settings')->rememberForever('privacy_page_url', function () {
@@ -101,11 +126,13 @@ class LayoutComposer
});
}
private function getCategories()
{
return Category::searchable();
}
private function getMostSearchedKeywords()
{
return Cache::remember('most_searched_keywords', now()->addHour(), function () {
@@ -113,21 +140,25 @@ class LayoutComposer
});
}
private function getPrimaryMenu()
{
return new MegaMenu(setting('storefront_primary_menu'));
}
private function getCategoryMenu()
{
return new MegaMenu(setting('storefront_category_menu'));
}
private function getCart()
{
return Cart::instance();
}
private function getWishlist()
{
if (auth()->guest()) {
@@ -137,15 +168,12 @@ class LayoutComposer
return auth()->user()->wishlist()->pluck('product_id');
}
private function getFooterMenuOne()
{
return $this->getFooterMenu(setting('storefront_footer_menu_one'));
}
private function getFooterMenuTwo()
{
return $this->getFooterMenu(setting('storefront_footer_menu_two'));
}
private function getFooterMenu($menuId)
{
@@ -155,6 +183,13 @@ class LayoutComposer
});
}
private function getFooterMenuTwo()
{
return $this->getFooterMenu(setting('storefront_footer_menu_two'));
}
private function getFooterTags()
{
$tagIds = setting('storefront_footer_tags', []);
@@ -166,18 +201,6 @@ class LayoutComposer
);
}
public function footerTagsCallback($tagIds)
{
return function () use ($tagIds) {
return Tag::whereIn('id', $tagIds)
->when(! empty($tagIds), function ($query) use ($tagIds) {
$tagIdsString = collect($tagIds)->filter()->implode(',');
$query->orderByRaw("FIELD(id, {$tagIdsString})");
})
->get();
};
}
private function getCopyrightText()
{
@@ -188,11 +211,13 @@ class LayoutComposer
]);
}
private function getAcceptedPaymentMethodsImage()
{
return $this->getMedia(setting('storefront_accepted_payment_methods_image'));
}
private function getSchemaMarkup()
{
return Schema::webSite()
@@ -200,6 +225,7 @@ class LayoutComposer
->potentialAction($this->searchActionSchema());
}
private function searchActionSchema()
{
return Schema::searchAction()

View File

@@ -2,40 +2,64 @@
namespace Themes\Storefront\Http\ViewComposers;
use Illuminate\View\View;
use Modules\Support\Money;
use Modules\Product\Entities\Product;
use Modules\Category\Entities\Category;
use Modules\Product\Entities\ProductVariant;
class ProductIndexPageComposer
{
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
* @param View $view
*
* @return void
*/
public function compose($view)
{
$view->with([
'categories' => $this->categories(),
'minPrice' => $this->minPrice(),
'maxPrice' => $this->maxPrice(),
'latestProducts' => $this->latestProducts(),
]);
}
private function categories()
{
return Category::tree();
}
private function maxPrice()
private function minPrice()
{
return Money::inDefaultCurrency(Product::max('selling_price'))
$minProductPrice = Product::min('selling_price');
$minVariantPrice = ProductVariant::min('selling_price');
$minPrice = min($minProductPrice, $minVariantPrice);
return Money::inDefaultCurrency($minPrice)
->convertToCurrentCurrency()
->ceil()
->amount();
}
private function maxPrice()
{
$maxProductPrice = Product::max('selling_price');
$maxVariantPrice = ProductVariant::max('selling_price');
$maxPrice = max($maxProductPrice, $maxVariantPrice);
return Money::inDefaultCurrency($maxPrice)
->convertToCurrentCurrency()
->ceil()
->amount();
}
private function latestProducts()
{
return Product::forCard()->take(5)->latest()->get()->map->clean();

View File

@@ -15,7 +15,8 @@ class ProductShowPageComposer
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
* @param View $view
*
* @return void
*/
public function compose(View $view)
@@ -30,6 +31,7 @@ class ProductShowPageComposer
]);
}
private function schemaMarkup(Product $product)
{
return Schema::product()
@@ -43,11 +45,13 @@ class ProductShowPageComposer
->offers($this->offersSchema($product));
}
private function brandSchema(Product $product)
{
return Schema::brand()->name($product->brand->name);
}
private function aggregateRatingSchema(Product $product)
{
return Schema::aggregateRating()
@@ -55,15 +59,17 @@ class ProductShowPageComposer
->ratingCount($product->reviews()->count());
}
private function offersSchema(Product $product)
{
return Schema::offer()
->price($product->selling_price->convertToCurrentCurrency()->amount())
->price(($product->variant ?? $product)->selling_price->convertToCurrentCurrency()->amount())
->priceCurrency(currency())
->availability($product->isInStock() ? ItemAvailability::InStock : ItemAvailability::OutOfStock)
->url($product->url());
}
private function getCategoryBreadCrumb(Collection $categories)
{
$breadcrumb = '';

View File

@@ -2,6 +2,7 @@
namespace Themes\Storefront\Http\ViewComposers;
use Illuminate\View\View;
use Modules\Category\Entities\Category;
class StorefrontTabsComposer
@@ -9,7 +10,8 @@ class StorefrontTabsComposer
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
* @param View $view
*
* @return void
*/
public function compose($view)
@@ -19,6 +21,7 @@ class StorefrontTabsComposer
]);
}
private function getCategories()
{
return ['' => trans('admin::admin.form.please_select')] + Category::treeList();