feat: implement hierarchical category selection with a tree view in product and category forms.
This commit is contained in:
@@ -27,7 +27,10 @@ class ProductCategoryController extends Controller
|
||||
|
||||
public function create()
|
||||
{
|
||||
$categories = \App\Models\ProductCategories::all();
|
||||
$categories = \App\Models\ProductCategories::with('children')
|
||||
->whereNull('parent_id')
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
return view('administrator.pages.product.categories.create', compact('categories'));
|
||||
}
|
||||
|
||||
@@ -43,7 +46,11 @@ class ProductCategoryController extends Controller
|
||||
if (!$category) {
|
||||
return redirect()->route('products.group.index')->with('error', 'Category not found');
|
||||
}
|
||||
$categories = \App\Models\ProductCategories::where('id', '!=', $id)->get();
|
||||
$categories = \App\Models\ProductCategories::with('children')
|
||||
->whereNull('parent_id')
|
||||
->where('id', '!=', $id)
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
return view('administrator.pages.product.categories.edit', compact('category', 'categories'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user