Browse Source

增加has

master
李可松 4 years ago
parent
commit
3bf5018f47
  1. 8
      app/Http/Controllers/Api/AgentProductController.php

8
app/Http/Controllers/Api/AgentProductController.php

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

Loading…
Cancel
Save