Endrit Sheholli
Endrit Sheholli

Reputation: 35

Accessing Object Data in Laravel

I have a question about accessing data in an object; this is the object:

RowCollection {#2909 ▼
  #heading: array:11 [▼
    0 => "account_level_i"
    1 => "account_level_ii"
    2 => "account_level_iii"
    3 => "date"
    4 => "transaction_type"
    5 => "num"
    6 => "name"
    7 => "class"
    8 => "memodescription"
    9 => "split"
    10 => "amount"
  ]
  #title: "Profit and Loss Detail"
  #items: array:6 [▼
    0 => CellCollection {#2915 ▼
      #title: null
      #items: array:11 [▼
        "account_level_i" => "   Income"
        "account_level_ii" => "      4000-1 Life Insurance"
        "account_level_iii" => "      4000-1 Life Insurance"
        "date" => "05/09/2018"
        "transaction_type" => "Deposit"
        "num" => null
        "name" => "John Hancock"
        "class" => "Wealth"
        "memodescription" => "JOHN HANCOCK USA  AG PREAUTHORIZED ACH CREDIT JOHN HANCOCK USA  AGENCYIND         180509"
        "split" => "1000-6 People's Bank Checking"
        "amount" => 2265.1
      ]
    }
    1 => CellCollection {#2919 ▶}
    2 => CellCollection {#2923 ▶}
    3 => CellCollection {#2927 ▶}
    4 => CellCollection {#2931 ▶}
    5 => CellCollection {#2935 ▶}
  ]
}

I need to access the heading data; I know how to access the items.

Upvotes: 0

Views: 94

Answers (1)

John Halsey
John Halsey

Reputation: 2008

You can use the getAttributes() method to get a model attributes if that's what you mean.

So if you had the model object in a variable I'm pretty sure you can do $model->getAttributes() to give you all those headers.

Upvotes: 1

Related Questions