2017-07-28 53 views

回答

2

正確的語法是:

ModelName::where('updated_at','<=', Carbon::today()) 
    ->firstOrCreate(['bot_id' => 10, 'bot_text' => $botTxt->id]); 

而且,由於firstOrCreate()使用質量分配功能,請確保你定義在ModelName$fillable屬性:

protected $fillable = ['bot_id', 'bot_text']; 
+0

我什麼固定不工作,你可以檢查'dd($ db);'每次'+ exists:true' !!!!例如,當我每次將mySql數據中的'updated_at'更改爲'2017-07-28 18:03:49'或'2017-07-25 18:03:49'時 –