|
|
|
@ -88,10 +88,10 @@ class AgentProduct extends BaseModel |
|
|
|
public static function list($agent_id) |
|
|
|
{ |
|
|
|
return static::withoutGlobalScope('orderById') |
|
|
|
->whereDoesntHave('agentProductItem', function ($query) { |
|
|
|
return $query->whereHas('product', function ($query) { |
|
|
|
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); |
|
|
|
}); |
|
|
|
->where(function ($query) { |
|
|
|
$query->whereHas('product', function ($query) { |
|
|
|
return $query->where([['stock', '>', 0], ['status', '=', ProductStatus::ON_SALE]]); |
|
|
|
})->orWhere('product_id', 0); |
|
|
|
}) |
|
|
|
->where('stock', '>', 0)->where(['agent_id' => $agent_id, 'status' => ProductStatus::ON_SALE]) |
|
|
|
->select('id', 'sale', 'product_id', 'price', 'original_price', 'title', 'pictures'); |
|
|
|
|