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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3CyzyEc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire