A
A
Artem Prokhorov2021-03-18 18:58:10
Laravel
Artem Prokhorov, 2021-03-18 18:58:10

Eloquent "model name"::all() produces a huge array in which there are table columns (which I need) and a bunch of unnecessary information. How to fix?

The table elements are immediately visible there Main, Header, Footer, and so on. (There's even more, I copied it to make it clear)

object(Illuminate\Database\Eloquent\Collection)#282 (1) {
  ["items":protected]=>
  array(5) {
    [0]=>
    object(App\Models\Post)#283 (27) {
      ["table":protected]=>
      string(5) "posts"
      ["timestamps"]=>
      bool(false)
      ["connection":protected]=>
      string(5) "mysql"
      ["primaryKey":protected]=>
      string(2) "id"
      ["keyType":protected]=>
      string(3) "int"
      ["incrementing"]=>
      bool(true)
      ["with":protected]=>
      array(0) {
      }
      ["withCount":protected]=>
      array(0) {
      }
      ["perPage":protected]=>
      int(15)
      ["exists"]=>
      bool(true)
      ["wasRecentlyCreated"]=>
      bool(false)
      ["attributes":protected]=>
      array(5) {
        ["id"]=>
        int(2)
        ["title"]=>
        string(6) "Header"
        ["desc"]=>
        string(11) "Header page"
        ["text"]=>
        string(19) "Text of header page"
        ["date"]=>
        string(10) "2020-10-10"
      }
      ["original":protected]=>
      array(5) {
        ["id"]=>
        int(2)
        ["title"]=>
        string(6) "Header"
        ["desc"]=>
        string(11) "Header page"
        ["text"]=>
        string(19) "Text of header page"
        ["date"]=>
        string(10) "2020-10-10"
      }
      ["changes":protected]=>
      array(0) {
      }
      ["casts":protected]=>
      array(0) {
      }
      ["classCastCache":protected]=>
      array(0) {
      }
      ["dates":protected]=>
      array(0) {
      }
      ["dateFormat":protected]=>
      NULL
      ["appends":protected]=>
      array(0) {
      }
      ["dispatchesEvents":protected]=>
      array(0) {
      }
      ["observables":protected]=>
      array(0) {
      }
      ["relations":protected]=>
      array(0) {
      }
      ["touches":protected]=>
      array(0) {
      }
      ["hidden":protected]=>
      array(0) {
      }
      ["visible":protected]=>
      array(0) {
      }
      ["fillable":protected]=>
      array(0) {
      }
      ["guarded":protected]=>
      array(1) {
        [0]=>
        string(1) "*"
      }
    }
    [1]=>
    object(App\Models\Post)#284 (27) {
      ["table":protected]=>
      string(5) "posts"
      ["timestamps"]=>
      bool(false)
      ["connection":protected]=>
      string(5) "mysql"
      ["primaryKey":protected]=>
      string(2) "id"
      ["keyType":protected]=>
      string(3) "int"
      ["incrementing"]=>
      bool(true)
      ["with":protected]=>
      array(0) {
      }
      ["withCount":protected]=>
      array(0) {
      }
      ["perPage":protected]=>
      int(15)
      ["exists"]=>
      bool(true)
      ["wasRecentlyCreated"]=>
      bool(false)
      ["attributes":protected]=>
      array(5) {
        ["id"]=>
        int(5)
        ["title"]=>
        string(5) "Links"
        ["desc"]=>
        string(10) "Links page"
        ["text"]=>
        string(18) "Text of links page"
        ["date"]=>
        string(10) "2019-07-07"
      }
      ["original":protected]=>
      array(5) {
        ["id"]=>
        int(5)
        ["title"]=>
        string(5) "Links"
        ["desc"]=>
        string(10) "Links page"
        ["text"]=>
        string(18) "Text of links page"
        ["date"]=>
        string(10) "2019-07-07"
      }
      ["changes":protected]=>
      array(0) {
      }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question