I have two columns in a table called expired(boolean)
and expire_date(timestamp)
. I m running a scheduler to check if a coupon is expired or not in everyMinute()
while updating the expired
column values using foreach, I have found that its changing the expired_date column value with todays date. I found this weird or may be I am messing up with the pass by reference thing.. here is the code
$schedule->call(function () {
CoursePromotion::where('expired',0)
->whereDate('expire_date','<',Carbon::today())
->update(['expired' => 1]);
})->everyMinute();
here is the result,
DB before updating
DB after running the php artisan schedule:run
command
Can anyone tell me why the expired_date has been updated with todays date?