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]);
}
}