<?php
namespace App\Http\View\Composers;

use Illuminate\View\View;
use App\Page;
use App\Option;
use Auth;

class BackendComposer
{
	public function compose(View $view)
	{
        $currentUser = Auth::user();
        $status = session()->get('status');
        $home = Page::whereHas('post', function($q) {
            $q->where('slug', '/');
        })->first();
        $optionsAll = Option::all();
        foreach($optionsAll as $option) {
            $options[$option->name] = $option->value;
        }
        $options = json_decode(json_encode($options));

		$view->with([
		    'currentUser'=> $currentUser,
            'status' => $status,
            'options' => $options,
            'home' => $home
        ]);
	}
}
