0

I'm pulling data from Airtable, which returns like so:

Illuminate\Support\Collection {#496 ▼
  #items: array:11 [▼
    0 => array:3 [▼
      "id" => "rec4CaAx5EwGGi0I3"
      "fields" => array:8 [▼
        "description" => "Soft covers for switches"
        "price" => 7
        "tags" => array:2 [▼
          0 => "recvPyxXM6GdIjgEr"
          1 => "recvskfZPFMRPXzEb"
        ]

I can find how to convert to:

Collection of Objects of arrays, or even

Collection of Collections of Collections using recursive methods,

but not

Collection of Objects of Objects (of Objects)

so I can access the data like $data->fields->name like I can with normal Eloquent fetched results

Mike Thrussell
  • 4,175
  • 8
  • 43
  • 59
  • 1
    please check this if it helps you click [here](https://stackoverflow.com/questions/51488623/how-can-i-convert-array-two-dimensional-to-collection-laravel) – Shailendra Jun 23 '21 at 19:16

1 Answers1

1

Turns out I can use json encode / decode to convert it all to objects and then collect it@

    $things = Airtable::table('things')->all();

    $things = json_decode(json_encode($things),FALSE);
    
    $things = collect($things);
Mike Thrussell
  • 4,175
  • 8
  • 43
  • 59