<?php namespace App\Composers;
use App\Products\Models\Product;
use Illuminate\View\View;
class FeaturedProductsComposer
{
/**
* @param View $view
*/
public function compose($view)
{
$rootProduct = Product::where('lft', '=', 1)->first();
$rootChildren = collect($rootProduct->findChildren());
$view->with('featuredProducts', $rootChildren->take(3));
}
}