lundi 17 octobre 2016

How to got all object from laravel eloquent relationship

I'm really confusing with Laravel something really crazy as the below data format after return from below function

if($action === 'edit'){
  $cat = Cat::find($this->request->segment(3))->CategoryDescriptions;
}
dd($cat);



Collection {#340 ▼
  #items: array:2 [▼
    0 => CategoryDescriptions {#341 ▼
      #table: "ab_category_descriptions"
      #connection: null
      #primaryKey: "id"
      #keyType: "int"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:8 [▼
        "id" => "43"
        "language_id" => "1"
        "name" => "Skincare"
        "meta_keywords" => ""
        "meta_description" => ""
        "description" => """
          <p>\n
          \tProducts from award-winning skin care brands</p>\n
          """
        "updated_at" => "0000-00-00 00:00:00"
        "created_at" => "0000-00-00 00:00:00"
      ]
      #original: array:8 [▶]
      #relations: []
      #hidden: []
      #visible: []
      #appends: []
      #fillable: []
      #guarded: array:1 [▶]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      +exists: true
      +wasRecentlyCreated: false
    }
    1 => CategoryDescriptions {#342 ▼
      #table: "ab_category_descriptions"
      #connection: null
      #primaryKey: "id"
      #keyType: "int"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:8 [▼
        "id" => "43"
        "language_id" => "2"
        "name" => "Skincare  KH"
        "meta_keywords" => ""
        "meta_description" => ""
        "description" => """
          <p>\r\n
          \tProducts from award-winning skin care brands</p>\r\n
          """
        "updated_at" => "0000-00-00 00:00:00"
        "created_at" => "0000-00-00 00:00:00"
      ]
      #original: array:8 [▶]
      #relations: []
      #hidden: []
      #visible: []
      #appends: []
      #fillable: []
      #guarded: array:1 [▶]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      +exists: true
      +wasRecentlyCreated: false
    }
  ]
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire