I am developing Laravel 5 app. In Which I want to log DB::table insert, update and deleted event with all New or changed(in case DB::table is being updated) DB::table Fields . I want simple reusable solution without writing too much of a code.
Asked
Active
Viewed 2,598 times
2 Answers
0
Simple solution is to use Eloquent Events.
You can bind events for all models you want globally using Service Provider:
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
User::creating(function ($user) {
// Do logging
});
}

Alexey Mezenin
- 158,981
- 26
- 290
- 279
-
thank,but i'm using DB::table for insert,update,delete data. in eloquent event it success , but how it in DB::table? – Dayat Fadila Jun 07 '16 at 05:47
-
@DayatFadila, almost same principle. Doom5 gave you a link to Query Events: https://laravel.com/docs/5.2/database#listening-for-query-events – Alexey Mezenin Jun 07 '16 at 06:05