Php 如何在Laravel 5.4中使用where in First或Create
如何使用这样的代码:Php 如何在Laravel 5.4中使用where in First或Create,php,laravel,model,laravel-5.3,laravel-eloquent,Php,Laravel,Model,Laravel 5.3,Laravel Eloquent,如何使用这样的代码: $db = ModelName::firstOrCreate(['bot_id'=>10, 'bot_text'=>$botTxt->id]) ->where('updated_at','<=', Carbon::today()); $db=ModelName::firstOrCreate(['bot\u id'=>10,'bot\u text'=>$botTxt->id]) ->其中('updated_at','正确的语法是: Model
$db = ModelName::firstOrCreate(['bot_id'=>10, 'bot_text'=>$botTxt->id])
->where('updated_at','<=', Carbon::today());
$db=ModelName::firstOrCreate(['bot\u id'=>10,'bot\u text'=>$botTxt->id])
->其中('updated_at','正确的语法是:
ModelName::where('updated_at','<=', Carbon::today())
->firstOrCreate(['bot_id' => 10, 'bot_text' => $botTxt->id]);
您还可以在firstOrCreate方法的first param中传递条件,如下所示:
$db = ModelName::firstOrCreate([
['updated_at','<=', Carbon::today()],
'bot_id'=>10,
'bot_text'=>$botTxt->id
]);
$db=ModelName::firstOrCreate([
['updated_at','I fixed any not working,您可以检查dd($db);
每次+存在时:true
!!例如,当我将updated_at
更改为2017-07-28 18:03:49
或2017-07-25 18:03:49
时,mySql数据中的值每次为true
$db = ModelName::firstOrCreate([
['updated_at','<=', Carbon::today()],
'bot_id'=>10,
'bot_text'=>$botTxt->id
]);