<?php

namespace App\Filters;

use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;

class SuperadminFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        // 1 = Superadmin
        if (session()->get('id_role') != 1) {
            return redirect()->to('/dashboard')->with('error', 'Hanya Superadmin yang bisa mengakses halaman ini.');
        }
    }
    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) {}
}