I have a problem similar to this post:
In short, my purpose and The question is:
- I have a " logarcords " table in my database.
- My event listeners in the global php are working on the default " Users " table.
- I want my Event Listener my " logrecords " table.
How can I do this:
- Will I configure my database tables that are elf ?
- Should I change something in global.php ?
Thank you for your support.
-------------------- Update --------------------
I realized that in my auth.php file, the default authentication model is set as:
'model' = & Gt; 'User'
But I want to listen and work with both the User and Logrecord models. So when I try to listen to events in my global.php file, the liveryware is trying to work with the user model automatically. That's because I had to configure my event listeners like this:
Part of my global.php file:
// The first example is the event :: $ UserLogRecord- & gt; User_id = $ user- ('auth.login', function ($ user) {$ userLogRecord = Logrecord :: firstOrCreate (array ('user_id' = & gt; $ user- & gt; ID) & gt; $ userLogRecord - & gt; Login_ last_at = Date ('YMD HK: I: S'); $ User Log Record-> Save ();}); // Second Example Event :: Listen ('auth.logout', function ( $ User) {$ userLogRecord = LogRecord :: First archive (array ('user_id' => $ user-> ID)); $ userLogRecord- & gt; User_id = $ user- & gt; ID; $ user People record-> logout_last_at = date ('YMD HH: I: S'); $ user Log Record-> Save ();});
This is working for now, but I am thinking that it is a good idea to edit my listeners like this My aim is to listen to some process with both the user and the logarcord model. It just serves my purpose, but I think I have to improve.
Any thoughts?
class logs elaborate {secure $ table = 'log';}
< / Pre>
Comments
Post a Comment