Support the ongoing development of Laravel.io →
posted 9 years ago
Database

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! :)

Last updated 2 years ago.
0

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.

Last updated 9 years ago.
0

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.

0

i dont think that is what he is looking for..

http://laravel.com/docs/5.1/database#listening-for-query-events is more appropriate...

0

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! :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

svolenszki svolenszki Joined 21 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.