¨4.0.1¨
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user