php - How can use a where in firstOrCreate in Laravel 5.4 -


how can use code this:

 $db = modelname::firstorcreate(['bot_id'=>10, 'bot_text'=>$bottxt->id]) ->where('updated_at','<=', carbon::today()); 

this 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 mass assignment feature, make sure you've defined $fillable property in modelname class:

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

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -