<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth;


class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

//    private $user;
//    private $signed_in;
//    private $is_admin;

    public function __construct()
    {
        $this->middleware(function ($request, $next) {
            $user = Auth::user();
            $signed_in = Auth::check();

            if(Auth::user() && Auth::user()->admin == 1){
               $is_admin = true;
            }else{
                $is_admin = false;

            }

            view()->share('signed_in', $signed_in);
            view()->share('user', $user);
            view()->share('is_admin', $is_admin);

            return $next($request);
        });

    }


}
