1
我在表中有兩列,分別叫做expired(boolean)
和expire_date(timestamp)
。我運行一個調度程序來檢查優惠券是否已過期everyMinute()
,同時使用foreach更新expired
列值,我發現它使用今天的日期更改expired_date列值。我發現這個奇怪的或可我參照的東西在這裏搞亂與通..是代碼laravel雄辯查詢生成器更新自定義時間戳字段沒有任何邏輯
$schedule->call(function() {
CoursePromotion::where('expired',0)
->whereDate('expire_date','<',Carbon::today())
->update(['expired' => 1]);
})->everyMinute();
這裏是結果,
DB更新
前DB運行後php artisan schedule:run
命令
誰能告訴我爲什麼expired_date已經更新爲今天的日期?
使用'Carbon :: now()',而不是'Carbon :: today()',第二個只返回日期而不是實際時間 – Vuldo