I have query like this
$query = MyModel::query()->where('status', 1);
and I want to get a different output
$result1 = $query->where('type', 1)->count();
$result2 = $query->where('type', 2)->count();
$result3 = $query->where('type', 3)->count();
result for $result2
and $result3
is wrong. So I try to get the raw queries from this
$result1 = $query->where('type', 1)->toSql();
$result2 = $query->where('type', 2)->toSql();
$result3 = $query->where('type', 3)->toSql();
the raw query shows
select * from `my_table` where `status` = ? and `type` = ?
select * from `my_table` where `status` = ? and `type` = ? and `type` = ?
select * from `my_table` where `status` = ? and `type` = ? and `type` = ? and type = ?
why Laravel added the where
condition to $result2
and $result3
?