Hello Team, sorry for the question again, but i tryed many hours before :)
ID 1: Cars = parent_id = NULL
ID 2: BMW = parent_id = 1
ID 3: Ford = parent_id = 1
ID 4: Bikes = parent_id = NULL
ID 5: Cross-Bike = parent_id = 4
With this Line i get all subcategories with the id.
public function subcategories($id)
{
$categories = category::where('parent_id',$id)->get();
return $categories;
}
localhost/shop/1
0
id 2
name "BMW"
parent_id 1
category_slug "bmw"
created_at "2019-11-21 00:00:00"
updated_at "2019-11-21 00:00:00"
1
id 3
name "Ford"
parent_id 1
category_slug "ford"
created_at "2019-11-21 00:00:00"
updated_at "2019-11-21 00:00:00"
Instead of ID, i like the category_slug "cars".
localhost/shop/cars
Route::get('/shop/{category_slug}', 'Shop\Product\ProductCategoryController@subcategories')
public function subcategories($category_slug)
{
$categories = category::where('parent_id',$category_slug)->get();
return $categories;
}
I get nothing :(