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

use CustomForm;

class CfCustomFormComposer
{
    public function compose($view)
    {
        $formSlug = $view->formSlug;

        $form = CustomForm::full()->with(array(
            'formItems' => function ($query) {
                $query->full()->with('formField')->orderBy('position');
            }
        ))->where('slug', $formSlug)
            ->where('status', 'published')->first();

        $view->with(array(
            'form' => $form
        ));
    }
}
