laravel eloquent rawメソッドでgroup byとcountのステータスを書き込む方法は? 私はmongodbを使用しています。laravel eloquent rawメソッドのmongo dbコレクションからのステータスフィールドのカウント方法
テスト目的のために、私はmysql(結果と下のクエリ)を使用してカウントを取ったが、mongodbでカウントする方法はわからない。
以下のコレクションとコードを確認してください。おかげ
SQL
SELECT count(*), status, date FROM booking WHERE date BETWEEN '2017-08-01' AND '2017-08-31' group by status, date order by date
結果
count status date 3 1 2017-08-01 1 2 2017-08-01 2 2 2017-08-02 1 3 2017-08-02 1 1 2017-08-03 1 2 2017-08-03 1 1 2017-08-04 1 2 2017-08-04 1 3 2017-08-04 1 3 2017-08-05 2 2 2017-08-06 2 3 2017-08-07 1 1 2017-08-08 1 2 2017-08-08 1 3 2017-08-08 1 1 2017-08-09 1 2 2017-08-09
Controller.php
ここでMongoのコレクション
{ "_id" : ObjectId("598c07a4f2017f945660bc1d"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-01T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }
{ "_id" : ObjectId("598c07b5f2017f945660bc1e"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-01T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c07c3f2017f945660bc1f"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-01T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }
{ "_id" : ObjectId("598c07cdf2017f945660bc20"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-01T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }
{ "_id" : ObjectId("598c07f5f2017f945660bc21"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-02T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c07fef2017f945660bc22"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-02T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c0802f2017f945660bc23"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-02T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c08a4f2017f945660bc24"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-03T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c08acf2017f945660bc25"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-03T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }
{ "_id" : ObjectId("598c08bcf2017f945660bc26"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-04T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c08c3f2017f945660bc27"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-04T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c08cef2017f945660bc28"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-04T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }
{ "_id" : ObjectId("598c08dff2017f945660bc29"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-05T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c08eef2017f945660bc2a"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-06T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c08f3f2017f945660bc2b"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-06T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c0901f2017f945660bc2c"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-07T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c0905f2017f945660bc2d"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-07T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c090ef2017f945660bc2e"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-08T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(2) }
{ "_id" : ObjectId("598c091af2017f945660bc2f"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-08T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(3) }
{ "_id" : ObjectId("598c091ff2017f945660bc30"), "cabinname" : "Kemptner Hütte", "checkin_from" : ISODate("2017-08-08T00:00:00Z"), "is_delete" : NumberLong(0), "status" : NumberLong(1) }