FEATURE: add tree view into creating new category
This commit is contained in:
@@ -17,7 +17,8 @@ class CreateNewCategory extends Controller
|
||||
public function getNew()
|
||||
{
|
||||
$category = new Category();
|
||||
$categories = Category::getTree();
|
||||
$categories = Category::getTree()->toArray();
|
||||
|
||||
$modules = Module::where('enabled', true)
|
||||
->get();
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
<select name="parentCategory">
|
||||
<option value=""> ---</option>
|
||||
@foreach($categories as $parentCategory)
|
||||
<option @if($parentCategory->id == $category->parent_id) selected
|
||||
@endif value="{{$parentCategory->id}}">{{$parentCategory->name}}</option>
|
||||
@include('categories::admin.snippets.optionParentCategories', ['level' => 0, 'selectedCategory' => $category, 'currentCategory' => $parentCategory])
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<option @if($currentCategory['id'] == $selectedCategory->parent_id) selected @endif value="{{$currentCategory['id']}}">
|
||||
{{str_repeat('-', $level)}} {{$currentCategory['name']}}
|
||||
</option>
|
||||
|
||||
@if(isset($currentCategory['children']))
|
||||
@foreach($currentCategory['children'] as $category)
|
||||
@include('categories::admin.snippets.optionParentCategories', ['selectedCategory' => $selectedCategory, 'currentCategory' => $category, 'level' => $level+1])
|
||||
@endforeach
|
||||
@endif
|
||||
Reference in New Issue
Block a user