atayahmet / laravel-nestable

Laravel 5 nested category/menu generator
MIT License
214 stars 52 forks source link

Retrieveing all Model vars. #45

Closed FooleanBool closed 6 years ago

FooleanBool commented 6 years ago

Thanks for this package. I've got all things working as I would like other than one thing: When using Category::nested()->get(); the collection returned only contains the standard vars:

  0 => array:5 [▼
    "id" => 15
    "name" => "General"
    "slug" => "general"
    "child" => array:1 [▶]
    "parent_id" => null
  ]

...however, my category table has a 'color' field, that I would also like returned with the collection. I have tried addings this variable to the config file:

return [
    'color'=>'color',
    'parent'=> 'parent_id',
    'primary_key' => 'id',

...with no success. Could you point me int he correct direction to add this functionality please? Thanks :)

FooleanBool commented 6 years ago

Got it. Add it to the config body, not the main array:

'body' => [
        'id',
        'name',
        'slug',
        'color'

Thanks agin for this package :)