如何在Laravel 5.4中使用firstOrCreate中的where

How can I use a code like this:

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

This is not working correctly.

The correct syntax is:

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

Also, since firstOrCreate() uses the mass assignment feature, make sure you've defined the $fillable property in the ModelName class:

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