diff --git a/packages/Sarga/API/Http/Controllers/Brands.php b/packages/Sarga/API/Http/Controllers/Brands.php index d1d65802a..74d019e39 100644 --- a/packages/Sarga/API/Http/Controllers/Brands.php +++ b/packages/Sarga/API/Http/Controllers/Brands.php @@ -68,7 +68,9 @@ class Brands extends \Webkul\RestApi\Http\Controllers\V1\Shop\ResourceController $query = $query->orderBy('position', 'desc')->orderBy('name', 'asc'); } - return $query->has('products'); + return $query->whereHas('flats', function($q){ + $q->where('status',1); + }); }); if (is_null($request->input('pagination')) || $request->input('pagination')) { diff --git a/packages/Sarga/Brand/src/Models/Brand.php b/packages/Sarga/Brand/src/Models/Brand.php index 838886139..f106dc824 100644 --- a/packages/Sarga/Brand/src/Models/Brand.php +++ b/packages/Sarga/Brand/src/Models/Brand.php @@ -8,6 +8,7 @@ use Laravel\Scout\Searchable; use Sarga\Brand\Contracts\Brand as BrandContract; use Webkul\Category\Models\CategoryProxy; use Webkul\Marketplace\Models\SellerProxy; +use Webkul\Product\Models\ProductFlatProxy; use Webkul\Product\Models\ProductProxy; class Brand extends Model implements BrandContract @@ -79,6 +80,10 @@ class Brand extends Model implements BrandContract return $this->hasMany(ProductProxy::modelClass(), 'brand_id'); } + public function flats():HasMany{ + return $this->hasMany(ProductFlatProxy::modelClass(), 'brand_id'); + } + public function sellers():BelongsToMany { return $this->belongsToMany(SellerProxy::modelClass(), 'seller_brands');