HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Eurotools/euro-tools.nl/app/Providers/ComposerServiceProvider.php
<?php
/**
 * Created by PhpStorm.
 * User: mike
 * Date: 19/05/17
 * Time: 08:41
 */

namespace App\Providers;


use App\KommaApp\Breadcrumb\BreadcrumbComposer;
use App\KommaApp\CustomerService\Models\CustomerService;
use App\KommaApp\Shop\Categories\CategoryComposer;
use App\KommaApp\Shop\Categories\CategoryService;
use App\KommaApp\Shop\Categories\Models\Category;
use App\KommaApp\Shop\Discounts\DiscountService;
use App\KommaApp\Shop\Discounts\DiscountServiceInterface;
use App\KommaApp\Shop\Products\Product\Product;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Contracts\View\View;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Register bindings in the container.
     *
     * @return void
     */
    public function boot()
    {
        // Using class based composers...
        view()->composer('site.partials.breadcrumb', BreadcrumbComposer::class);

        // Load cookie config into view
        view()->composer('site.partials.cookieIndex', function (View $view)
        {
            // Get config
            $cookieConsentConfig = config('cookie-consent');
            // Check if cookie exists
            $alreadyConsentedWithCookies = Cookie::has($cookieConsentConfig['cookie_name']);
            // Return with configuration
            $view->with(compact('alreadyConsentedWithCookies', 'cookieConsentConfig'));
        });

        view()->composer(['site.pages.customerservice', 'site.partials.footer'], function (View $view)
        {
            $servicePages = CustomerService::where('active', '=', true)->with('translation')->get();
            $view->with(compact('servicePages'));
        });

//        view()->composer([
//            'site.partials.footer',
//            'site.partials.mobile.navigation',
//            'site.partials.sideMenu',
//            'shop.pages.categories.index',
//            'shop.pages.products.show',
//            ], function (View $view) {
//            $categories = \App::make(CategoryService::class)->getAllCategories();
//            $view->with(compact('categories'));
//        });

        view()->composer([
            'site.partials.footer',
            'site.partials.mobile.navigation',
            'site.partials.sideMenu',
            'shop.pages.categories.index',
        ], CategoryComposer::class);

//        view()->composer('shop.partials.itemsGridLoop', function (View $view) {
//            $discount = null;
//            $viewData = $view->getData();
//            $products = $viewData['products'];
//            if(empty($viewData['isCategory'])) {
//                /** @var DiscountServiceInterface $discountService */
//                $discountService = \App::make(DiscountServiceInterface::class);
//
//                foreach ($products as $product) {
//                    /** @var Product $product */
//                    $product->discount = $discountService->getQuantityDiscountForASpecificDiscountable($product);
//                }
//
//                $view->with(compact('products'));
//            } else {
//                foreach ($products as $product) {
//                    /** @var Category $product */
//                    $categoryProductsWithDocuments = $product->getProducts()->has('documents')->first();
//                    if(count($product->documents) == 0 && !empty($categoryProductsWithDocuments)){
//                        $product->documents = $categoryProductsWithDocuments->documents;
//                    }
//
//                }
//            }
//        });

    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}