baum
baum copied to clipboard
How to set "scope" only once when mass assigning from array?
Hey! Is there a way to set this 'company_id' only once when building from array?
Seems a bit annoying to duplicate it to every array element when mass assigning with Category::buildTree($categories)
$root1 = Category::create(['name' => 'Root', 'company_id' => 1]);
$root2 = Category::create(['name' => 'Root', 'company_id' => 1]);
$child1 = Category::create(['name' => 'Child', 'company_id' => 1]);
$child2 = Category::create(['name' => 'Child', 'company_id' => 1]);
Same question also when mass assigning from array? It would be nice if I could pass my scopes array to BuildTree method.
Just to avoid adding keys to every line in array...
$categories = [
['family_id' => 1, 'name' => 'Category', 'children' => [
['family_id' => 1, 'name' => 'Category2', 'children' => [
['family_id' => 1, 'name' => 'Category3', 'children' => [
['family_id' => 1, 'name' => 'Category4'],
['family_id' => 1, 'name' => 'Category5'],
]],
]],
]],
];
Possibly related to or the same as #68
Not sure if this project is alive though.. @etrepat?