<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Laratrust\LaratrustFacade as Laratrust;

class HomeController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
      if (Laratrust::hasRole('admin')) return $this->adminDashboard();
      if (Laratrust::hasRole('member')) return $this->memberDashboard();
      return view('home');

    }

    protected function adminDashboard()
    {
    return view('dashboard.admin');
    }
    protected function memberDashboard()
    {
      $beliLogs = Auth::user()->beliLogs()->beli()->get();
      return view('dashboard.member', compact('beliLogs'));
      

    }


}
