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
@shuvoo you can simply do this:
Leads::whereDate('leadtime', now())->count();
what column type is leadtime
@snapey his comment above
// leadtime database colum name and thare have Timestamp formate
// 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
Not sure how that is related to date time but this should work
$getdata= Data::where('id', $id)->where('hits', '<', 'dailylimit')->get();
solved
$getdata= Data::where('id', $id)->whereColumn('hits', '<', 'dailylimit')->get();
thanks
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.