add array elements in laravel code example
Example 1: how to add values to an array in laravel
$array = array('foo' => 'bar');
$array = array_add($array, 'key', 'value');
Example 2: laravel return a single dimensional array
$catcount = 2;
$parents_ids = [];
for ($i = 0; $i < $catcount; $i++) {
$parents_ids[] = $userCategory[$i];
}
$subCats = Category::whereIn('parent_id', $parents_ids)->pluck('id');