jeudi 23 septembre 2021

Laravel firstOrNew based on created_at same date

I am using lumen. I want to use firstOrNew based on created_at. For example in my table there exists data for created_at = 2021-09-23 14:42:13 . For that cases it will update if request date value become that day. Here I tried with

$tableObj = User::firstOrNew([
        'created_at' => Carbon::today() // date('Y-m-d')
    ]);
$tableObj ->mobile= '5457874545';
$tableObj ->save();

Here it always inserted new row. Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire