nam_co
240
10
Laravel

where inside blade L5.4

Posted 2 years ago by nam_co

Hello, hope somebody can help me, Im trying to limit the DB calls by getting the collection onces and then filter using whereMonth, but Im getting a macro error

@php
    $users = Cache::remember('users', 60, function () {
                return \DB::table('users')->get();
            });
    $month_users = $users->whereMonth('created_at', date('m'))->count(); //this is what Im trying to do
    $month_users = \DB::table('users')->whereMonth('created_at', date('m'))->count();
    $lastmonth_users = \DB::table('users')->whereMonth('created_at', $lastmonth2)->count();
@endphp

thanks for any help

Please sign in or create an account to participate in this conversation.