Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shuvoo's avatar

laravel data time

i want to convet this in to laravel

SELECT `id` FROM `leads` WHERE DATE(`leadtime`) = CURDATE() ;

// leadtime  database colum name and thare have Timestamp formate 
Leads::where(DATE(`leadtime`), Carbon::now()->format('Y-m-d'))->count();

thanks in advance

0 likes
7 replies
Nakov's avatar
Nakov
Best Answer
Level 73

@shuvoo you can simply do this:

Leads::whereDate('leadtime', now())->count();
Nakov's avatar

@snapey his comment above

// leadtime database colum name and thare have Timestamp formate

Shuvoo's avatar
// hits and dailylimit  this colum name in same table 
AND hits < dailylimit

how to add this condition in there

$getdata= Data::where('id', $id)->get();
// actually im new in laravel 
Sinnbeck's avatar

Not sure how that is related to date time but this should work

$getdata= Data::where('id', $id)->where('hits', '<', 'dailylimit')->get();
Shuvoo's avatar

solved

$getdata= Data::where('id', $id)->whereColumn('hits', '<', 'dailylimit')->get();

thanks

Snapey's avatar

You are returning a collection of one item (the one with the id) How does the daily limit even matter?

And using get and returning a collection, you then need to iterate over the collection to get the data. Better to use first()

Please or to participate in this conversation.