<?php namespace App\Libs\Composers;

use Office;

class OfficesComposer
{
    use RelatedComposerTrait;

    public function compose($view)
    {
        $data = $view->getData();
        $page = $data['object'];
        $templateData = \ContactsTemplateConf
            ::full()->with('mainContact')->where('entry_id', $page->id)->first();

        $this->composeRelated($view, $templateData);
        $offices = Office::full()
            ->with('country', 'contact', 'contact.image')
            ->orderBy('website_objects.position', 'asc')->get();

        $view->with(array(
            'offices' => $offices,
            'templateData' => $templateData
        ));
    }
}
