<?php

namespace App\Providers;

use App\Accommodation;
use Illuminate\Support\ServiceProvider;
use Auth;
use App\User;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        view()->composer('layouts.app', function($view)
        {
            if(Auth::check()){
                $accommodation_id = User::where('user_id','=',Auth::user()->user_id)->pluck('accommodation_id')->first();
                $accommodation = Accommodation::find($accommodation_id);
                $view->with('accommodation', $accommodation);
            }

        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
