<?php

namespace App\Http\Controllers;

use App\Models\Pad;
use App\Models\Tabelas\Constants;
use App\Models\UserPad;
use App\Models\UserType;
use App\Models\Util\Menu;
use App\Models\Util\MenuItemsAdmin;
use App\Models\Util\MenuItemsTeacher;
use App\Models\Util\Status;
use App\Queries\UnidadeQuery;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class DashboardController extends Controller
{

    public function index() {

        $user = Auth::user();

        if($user->isTypeAdmin())
        {
            return view('dashboard',['menu' => Menu::HOME]);
        }

        if($user->isTypeTeacher())
        {   
            $userType = $user->profile(UserType::TEACHER);

            $userPads = 
                UserPad::initQuery()
                    ->whereUser($userType->id)
                    ->wherePadStatus(Status::ATIVO)
                    ->get();

            return view('dashboard', ['userPads' => $userPads, 'menu'=> Menu::HOME]);
        }
        
        if($user->isTypeDirector())
        {
            return view('dashboard', ['PADs' => Pad::all(), 'menu'=> Menu::HOME]);
        }

        if($user->isTypeCoordinator())
        {
            return view('dashboard', ['PADs' => Pad::all(), 'menu'=> Menu::HOME]);
        } 

        if($user->isTypeEvaluator())
        {   
            $userPads = 
                UserPad::initQuery()
                    ->whereUser($user->id)
                    ->wherePadStatus(Status::ATIVO)
                    ->get();

            return view('dashboard', ['userPads' => $userPads, 'menu'=> Menu::HOME]);
        }

        //return redirect()->route('login');
    }
}
