DB::table('customer_active_logs')
->where('customer_id', $customer->id)
->where('updated_at', '>', $today) // Every day make new log
->insert(['customer_id' => $customer->id, 'created_at' => $now, 'updated_at' => $now]);
I dont understand it. Does this code really work? What the where conditions doing with insert? What is this really doing? Can somebody explain it to me?
It is nonsense; the where Builder methods have zero effect; as such, they are not used in the resulting SQL. Conceptually, they are wrong anyway, you're inserting a new record, no constraint applies.