Welcome Guest, Not a member yet? Register   Sign In
intController() and __construct()
#5

(This post was last modified: 05-22-2022, 12:23 AM by dgvirtual.)

I have just noticed that I cannot access the variables initiated in BaseController initController method in the constructors of my controllers...

I have

$this->settingsModel = model('SettingsModel');
$this->settings = $this->settingsModel->keyValue();

in my BaseController initController method, and running

$hl = explode('-', $this->settings['booking_hours']);

in controller methods goes fine, but if I do this in

function __construct()

I get an error

Undefined property: App\Controllers\Booking::$settings

What would be the correct way to do things here? Maybe use initController with a parent call in my controller classes instead of __construct()? I could, of course, simply initiate the needed model and run the

$this->settings = $this->settingsModel->keyValue();

in the constructor...
==

Donatas G.
Reply


Messages In This Thread
intController() and __construct() - by enlivenapp - 07-30-2018, 01:26 PM
RE: intController() and __construct() - by dgvirtual - 05-22-2022, 12:20 AM
RE: intController() and __construct() - by kenjis - 05-22-2022, 02:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB