|
|
@ -64,7 +64,13 @@ class AgentProductController extends Controller |
|
|
} else { |
|
|
} else { |
|
|
$where = ['id' => $id, 'agent_id' => $this->agent_id, 'status' => ProductStatus::ON_SALE]; |
|
|
$where = ['id' => $id, 'agent_id' => $this->agent_id, 'status' => ProductStatus::ON_SALE]; |
|
|
} |
|
|
} |
|
|
$agent_product = AgentProduct::with(['coupon:tag,agent_product_id', 'product:id,type,extends', 'spec.productSpec:id,name,date']) |
|
|
|
|
|
|
|
|
$agent_product = AgentProduct::with([ |
|
|
|
|
|
'coupon:tag,agent_product_id', |
|
|
|
|
|
'product:id,type,extends', |
|
|
|
|
|
'spec' => function($query) { |
|
|
|
|
|
return $query->has('productSpec')->with('productSpec:id,name,date'); |
|
|
|
|
|
} |
|
|
|
|
|
]) |
|
|
->whereDoesntHave('agentProductItem', function ($query) { |
|
|
->whereDoesntHave('agentProductItem', function ($query) { |
|
|
return $query->whereHas('product', function ($query) { |
|
|
return $query->whereHas('product', function ($query) { |
|
|
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); |
|
|
return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); |
|
|
|