atayahmet / laravel-nestable

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

Update NestableTrait.php #4

Closed Sarav-S closed 8 years ago

Sarav-S commented 8 years ago

Multiple elements passed to attributes array is not getting applied. For example

Category::attr(['name' => 'parent_id', 'class' => 'form-control'])->renderAsDropdown(); 

Above line is supposed to take both name and class parameter. But only name is added to select box. Below line on 221 rejects all parameters except first element.

static::$parameters[$method][key($value)] = current($value);

So if the $value is array, then I'm looping them to add to $paramater variable

foreach ($value as $key => $attr) {
       static::$parameters[$method][$key] = $attr;
}
atayahmet commented 8 years ago

Hi @Sarav-S

I approved your PR. Thank you for contribute.