mardi 27 octobre 2015

laravel 5.1 mongodb (jenssegers/laravel-mongodb) querying dates now working right

i really stuck with that, hopefully someone can help :), first of all sorry for my English, i'm using laravel 5.1 with mongodb package (jenssegers/laravel-mongodb) to build a leads manager system. i'm trying to get the count of leads from deterrent times but the return answer is wrong - for example if for $today_count i keep get the same as total count (i know it wrong, i can see by the dates in the collection) my code looks like that:

public function getCount()
{
    $client_id = \Auth::client()->id;
    $today = Carbon::now()->startOfDay();
    $today->setTimezone(Client::getTimezone())->toDateTimeString();
    $last_week = $today->subWeek();
    $today_count = Lead::where('client_id',$client_id)->where('created_at','>',$today)->get()->count();
    $last_week_count = Lead::where('created_at',$last_week)->where('client_id',$client_id)->get()->count();
    $forever = Lead::where('client_id',$client_id)->get()->count();
    return ['today' => $today_count, 'last_week' => $last_week_count, 'forever' => $forever];
}

any idea why is it happens and what sould i do to get the correct answer? thank you all!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire