这是一个例子
变量1:
$encodedtoday = MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'Mark')->count();
变量2:
$encodedtoday = MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'Michael')->count();
变量3:
$encodedtoday = MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'John')->count();
我知道这可以在数组或其他东西中完成。请告诉我
答案 0 :(得分:3)
试试这样:
$encodedtoday = MemberProfile::whereDate('created_at', '=', $today )
->whereIn('encoded_by', ['Mark','Michael','John'])->count();
希望这有帮助
答案 1 :(得分:1)
您可以创建一个由名称编码的数组,然后传递给whereIn条件,如下所示:
$encoded_by = ['Mark','Michael','John'];
$encodedtoday = MemberProfile::whereDate('created_at', '=', $today)
->whereIn('encoded_by', $encoded_by)->count();
return $encodedtoday;
答案 2 :(得分:0)
您可以定义$encodedtoday = 0;
然后继续为所有人添加计数:
$encodedtoday += MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'Mark')->count();
$encodedtoday += MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'Michael')->count();
$encodedtoday += MemberProfile::whereDate('created_at', '=', $today )
->where('encoded_by', 'John')->count();
所以在这里,$encodedtoday
将有最终计数。