Dear All!
In an application I have to track data table record changes, so I need to define some event which fires on ever database query.
Can anybody show me some example or give any idea where to start?
The reason is:
The user post forms but not all fields required, but by the time, the missing fields must be filled. I decided I make a notify table where I can store the user, the table name, the filed which has to be updated and times.
If I can make a global query event, where I can handle the notifes, and If a "must updated" filed updated, I remove the notification.
I hope this is clear, my english is not so perfect! :)
Is it a realy mindless question or a hard nut to crack? I Googled this topic a lot, but I can not find any direction.
Finally I did a workout, a really ugly one, but functional.
I found out that, the Builder.php in the folder /vendor/laravel/framework/src/Illuminate/Database/Query does the update queries in the public function update (array $values){...
So in this function befor returning the $this-connection->update(...) i did my logic and works fine.
Now if a record updated, I look up my notification table and if there is any notification for that table that record, and the reference value is different than the updated value, I delet the notification.
I keep this thread unsolved, because this is not what I want, but now I can move to the next stage.
i dont think that is what he is looking for..
http://laravel.com/docs/5.1/database#listening-for-query-events is more appropriate...
This is exactly what I needed! You made my day shez1983!
Thanks for all guys, this is a great place for Laravel developers, I will come back regularly! :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community