My code returns the first row from a Laravel $data = DB::table('sometable')->select('id')->get(); using:
$row = $data->first();
I can then return id using:
$row->id;
How can I now add an array with key 'moredata' to that row collection object for referencing later in the code? I've tried:
$row->put('moredata', $moredata);
Where $moredata is a populated array and 'moredata' is not a field in the table. Laravel throws the error 'Call to undefined method stdClass::put()'. I could convert to an array and simply extend the array, just wondered if it could be done retaining the Laravel collection structure?