Mongodb aggregate not working

Hi,

Any body help me. I am using mongdb aggregate simple query but not return any result.

$data = Transaction::aggregate( [ [ "\$match" => [ "shift_id" => new ObjectID($data['shift_id']) ], ], [ "\$group" => [ "_id" => [ "payment_method" => "\$paymentMethod" ], "total" => [ "\$sum" => "\$transactionAmount", ] ], ], ] );

But when i run this query mongo and it returns result.

db.transactions.aggregate([ { $match: { shift_id: ObjectId("593d0ed750692f04ca6f2e44") } }, { $group: { _id: {paymentMethod:"$paymentMethod"}, "total": {$sum:"$transactionAmount"} } } ])

Thank you

I would stick with single quotes around the mongo variables

Transaction::aggregate(
                [
                    [
                        '$match' => [
                            'shift_id' => $data['shift_id']
                        ],
                    ],

                    [
                        '$group' => [
                            'id' => ['paymentmethod' => '$paymentMethod'],
                            "total" => ['$sum' => '$transactionAmount',]
                        ],
                    ],
                ]
            );