Hello guys.
I need some advice on CI4. In ci3 I extended the controller with the MY_controller like this:
PHP Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
}
}
class Guest_Controller extends MY_Controller //Controller for Not Logged (free)
{
function __construct()
{
parent::__construct();
}
}
class Logged_Controller extends MY_Controller //Controller for ALL Logged
{
function __construct()
{
parent::__construct();
if (!$this->ion_auth->logged_in())
{
redirect('auth/login');
}
}
}
class Admin_Controller extends MY_Controller //Controller for Admin
{
function __construct()
{
parent::__construct();
if (!$this->ion_auth->logged_in())
{
redirect('auth/login');
}
else
{
if(!$this->ion_auth->is_admin())
{
$this->session->set_flashdata('flashError', 'This page is only for ADMIN');
redirect('example_logged');
}
}
}
}
so in each controller that i created, I extended the class I needed (adminController, LoggedController etc)
How can I get the same result with the BaseController? What class do I extend in my controllers, depending on whether they are admin, logged etc?
Thanks to all