cache responces achyklar

This commit is contained in:
merdan 2022-12-17 13:08:28 +05:00
parent 427d7bfc79
commit fb3bb6ba44
2 changed files with 8 additions and 1 deletions

View File

@ -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')) {

View File

@ -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');