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/SBogers95/rentman.io/app/Komma/CustomerLogos/CustomerLogoComposer.php
<?php

namespace App\Komma\CustomerLogos;

use App\Komma\CustomerLogos\Models\CustomerLogo;

class CustomerLogoComposer
{
    const LOGO_SLIDER_AMOUNT = 10;

    public function compose($view)
    {
        $logos = CustomerLogo::with('translation', 'images')
            ->has('images')
            // We need to use a join to select the active solution because that is defined on the translations
            ->join('customer_logo_translations', 'customer_logos.id', '=',
                'customer_logo_translations.customer_logo_id')
            ->select('customer_logos.*', 'customer_logo_translations.active', 'customer_logo_translations.language_id')
            ->where('active', 1)
            ->where('language_id', \App::getLanguage()->id);

        if ($view->getName() == 'site.components.customerLogoSlider') {
            $logos = $logos->take(self::LOGO_SLIDER_AMOUNT);
        }

        $logos = $logos->get()->shuffle();

        $view->with(['customerLogos' => $logos]);
    }
}