Nithil George Nithil George - 4 months ago 11x
JSON Question

How to create a blob in MongoDB using laravel

I am using Laravel4 PHP Framework, my web application has to handle JSON format APIs.

First part of My problem is, each time when i get a subscription, deviceID and listID (where list ID is the the list which was subscribed by the device having deviceID) is received by the web application.
For each deviceID received we have to create a blob having deviceID like


when the same device subscribe multiple list i have to update subscription, similerly when new device subscribes, a new document has to be created as above.

Second part of my problem is our web will create a offer campaigns for each Lists.Each campaign would have fiels like Title, Icon, Image,Detailed description etc.
when a campaign is ON, this campaign has to inserted in to offers array of above document as an object Like:

offers [{campaign1}]

The campaign would have many fields.

I have tried

subscriptions: [{
list_id: "14Q3"}, {list_id: "8989"}
offers: [ { title: "50% off", qty: 25 }, { title: "20% off", qty: 50 } ],

This worked.
I couldn't insert or retrieve or updaate any data using Laravel4.

I am using MongoDB and Laravel4

Sorry for bad english
Please help me


As I have Succeeded in inserting as following

           '_id' => $subscriber->device_id,
           'subscriptions' => array(array('list_id' => $subscriber->list1_id)),

For pushing into Subscriptions array I used following code

Subscription::where('_id',$subscriber->device_id)->push('subscriptions', array('list_id' => $subscriber->list1_id));