I an Individuals Table where i store some data for few pages by their page name and item type with a key
Schema::create('individuals', function (Blueprint $table) {
$table->increments('id');
$table->string('page');
$table->string('key');
$table->json('content');
$table->timestamps();
});
I select a collection by
dd(Individuals::wherePage('home')->get(['key','content'])->toArray());
and I get this output
array:5 [▼
0 => array:2 [▼
"key" => "title"
"content" => "Two Seas Residence"
]
1 => array:2 [▼
"key" => "overview"
"content" => "["Living room with 4 sofas","Non-smoking rooms","Ironing Facilities","Fire Place (wood)","LED TV with cable connection","Free WiFi access","Gas hob","Fridge & Microwave"]"
]
2 => array:2 [▼
"key" => "intro"
"content" => """
It is situated less than a kilometer from the centre of Ooty. It consists two number of three-bedroom and three number of two-bedroom cottages with common facilities.\n
\n
This is a luxury Cottage built to satisfy the discerning taste of a vacationer. The cottage is a wonderful establishment that is fully furnished with carefully selected interiors that blends seamlessly with modern scenery. Two Seas is not only a cozy place but also a house provided with all luxuries and convenience. Ideal for family holiday, a quiet get away for a couple or high profile guests.\n
\n
Open plan living room with kitchen and dining areas. The high ceiling, fire place (flame picture can be viewed from almost anywhere in the living room), paintings and decoration make the living room a lovely place to be. Well equipped kitchen with everything you need for self-catering with lovely views over hillside. Spacious bedrooms with king size beds, full size wardrobe, dressing table with vanity mirror, bedside tables and access to balconies. En-suite shower to all rooms with Italian designer sanitary ware with Toto accessories.
"""
]
3 => array:2 [▼
"key" => "banner"
"content" => "http://content.twoseasresidence.com/wp-content/uploads/2015/08/front-wide-e1438797045904.jpg"
]
4 => array:2 [▼
"key" => "map"
"content" => "http://dev.twoseasresidence.com/frontend/img/maps.png"
]
]
But I need to flatten the collection based on the value of the key and value of the content so that i can select an item like
$array['map'] or $collection->map //results http://dev.twoseasresidence.com/frontend/img/maps.png
Any ideas?