public static function filterCategoriesByParentName($query, $name) {
        $obj = \Delatbabel\NestedCategories\Models\Category::where('name', $name)
            ->whereNull('parent_id')
            ->first();
        if ($obj) {
            $query->where('parent_id', $obj->id);
        } else {
            $query->where('name', $name);
        }
    }
public static function filterCategoriesByParentName($query, $name) {
        $obj = \Delatbabel\NestedCategories\Models\Category::where('name', $name)
            ->whereNull('parent_id')
            ->first();
        if ($obj) {
            $query->where('parent_id', $obj->id);
        } else {
            $query->where('name', $name);
        }
    }
public static function filterCategoriesByParentName ( $ query , $ name ) { $ obj = \ Delatbabel \ NestedCategories \ Models \ Category :: where ( 'name' , $ name ) -> whereNull ( 'parent_id' ) -> first ( ) ; if ( $ obj ) { $ query -> where ( 'parent_id' , $ obj -> id ) ; } else { $ query -> where ( 'name' , $ name ) ; } }
Returns a query to find subcategories of a parent category by the name.

Only picks subcategories under a parent category (parent category has
parent_id IS NULL).

@param Builder $query
@param string $slug
@return Builder
Returns a query to find subcategories of a parent category by the name .