Welcome Guest, Not a member yet? Register   Sign In
Events and Controllers...
#1

Hi everyone,
I like to achieve simply logging the views of my pages in the database. Still learning CI4 though...
I found the Events and was looking at it the whole night. I have a Controller "Statistics" as well as a model. I've read I have to add the full namespace like App\Controllers\Statistics.
But
PHP Code:
Events::on('post_system', ['\App\Controllers\Statistics''write']); 
won't work still as it let's me know it isn't called static.

So... any help and/or additional insights how the Events work? I didn't figure it yet, obviously Smile
Reply
#2

Quote:Note that the second parameter can be any form of callable that PHP recognizes:
https://codeigniter4.github.io/CodeIgnit...g-an-event

It seems you need to learn PHP.
See https://www.w3schools.com/php/keyword_static.asp
Reply
#3

try this
Events::on('post_system', '\App\Controllers\Statistics::write');
Reply
#4

thank you @devo Sometimes it's so simple
Reply




Theme © iAndrew 2016 - Forum software by © MyBB