I am trying to get 3 counts from a collection called leads. Where I have to get lead_nextaction is equal to todays date, lead_nextaction is less than todays date and lead_nextaction is greater than todays date. I am using laravel and mongodb. I also have to get the count after some where queries. I get the count only for the first $leadcntT.
$q=lead::query();
$q->where('lead_status',$enq_status);
$leadcntT = $q->where('lead_nextaction', '=', date('Y-m-d').' 00:00:00')
->count();
$leadcntP = $q->where('lead_nextaction', '<', date('Y-m-d').' 00:00:00')
->count();
$leadcntF = $q->where('lead_nextaction', '>', date('Y-m-d').' 00:00:00')
->count();
return $leadcntT.' '.$leadcntP.' '.$leadcntF ;
}
I have tried something like this but it does not work.
This is how my MS SQL query looks
exec('select t.range as [Sr], count(*) as [c]
from (
select case
when CAST(next_action_date as date)=CAST(getdate() as date) then ''T''
when CAST(next_action_date as date)<CAST(getdate() as date) then ''P''
when CAST(next_action_date as date)>CAST(getdate() as date) then ''F''
end as range
from crm_enquiry)
Please help me out. A big thankyou in advance.
via Sanjana Anand