david19
7 months ago
359
4
Laravel

Query show sub-category

Posted 7 months ago by david19

Hello Team,

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

I would like a view with only BMW and Ford. But i get allways with the Cross Bike :( Relationship Category Model

return $this->hasMany('App\Category', 'parent_id');
public function subcategories()
    {
      $categories = Category::where('parent_id')->???->get();
    }

Please sign in or create an account to participate in this conversation.