<?php namespace App\Libs\Composers\CF;

use Menu;
use Office;

class CfFooterComposer
{

    public function compose($view)
    {
        $cfMenu = Menu::with(array(
            'menuItems' => function ($query) {
                $query->orderBy('position', 'asc');
            }
        ))->where('slug', 'footer-cf-menu')->first();

        $solutionsMenu = Menu::with(array(
            'menuItems' => function ($query) {
                $query->orderBy('position', 'asc');
            }
        ))->where('slug', 'footer-cf-solutions-menu')->first();

        $resourcesMenu = Menu::with(array(
            'menuItems' => function ($query) {
                $query->orderBy('position', 'asc');
            }
        ))->where('slug', 'footer-cf-resources-menu')->first();

        $offices = Office::full()
            ->with('country')
            ->where('status', 'published')
            ->orderBy('website_objects.position', 'asc')->get();

        $view->with(array(
            'cfMenu' => $cfMenu,
            'resourcesMenu' => $resourcesMenu,
            'solutionsMenu' => $solutionsMenu,
            'offices' => $offices
        ));
    }
}
