laravelでmongodbに接続して、groupbyでグループごとの集計データをとってくる2 mongodb

(参考まで)
<pre class= brush:php >
ModelName::selectRaw( COUNT(*) AS count boolean_one date_trunc(&yen; day&yen; created_at) as date )
->where( created_at >= Carbon::now()->subMonth())
->where( boolean_two = &#36;booleanTwo)
->where( string_value LIKE &#36;searchForString . % )
->groupBy( boolean_one )->groupBy( date )
->orderBy( date )->get();
</pre>
<br><pre class= brush:php >
ModelName::raw(function (&#36;collection) &#123;
return &#36;collection->aggregate([
[
&#36;match => [
created_at => [ &#36;gt => new MongoDate(Carbon::now()->subMonths(1)->timestamp)] boolean_two => &#36;booleanTwo
string_value => [ &#36;regex => new MongoRegex( /.* .&#36;searchForString. .*/ )]
]
]
[
&#36;group => [
_id => [
month => [ &#36;month => &#36;created_at ]
day => [ &#36;dayOfMonth => &#36;created_at ]
year => [ &#36;year => &#36;created_at ]
boolean_one => &#36;boolean_one
]
count => [
&#36;sum => 1
]
]
]
]);
&#125;);
</pre>