<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware(['auth', 'check.user_status']);
    }

    /**
     * Show the application CLIENT dashboard.
     *
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Foundation\Application
     */
    public function index()
    {
        if (Auth::user()->hasRole("client")) {
            if (Auth::user()->can("isContractAdmin")) {
                return view('home.home');
            }
            return redirect()->route('basic.search.index');
        }
        return redirect()->route('dashboard');
    }
}
