<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        if ($this->isLoggedIn()) {
            $user = $this->currentUser();
            if ($user['role'] === 'admin') {
                return redirect()->to('/admin');
            } elseif ($user['role'] === 'agent') {
                return redirect()->to('/agent');
            }
        }

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