SG
Size: a a a
SG
SG
return Zone::with(['report.region', 'landfills', 'vehicles', 'auto_park', 'checks', 'media', 'zoneTitle'])
мне нужно по связи 'landfills' сделать count(), но также чтобы 'landfills' тоже оставался в запросеwithCount('landfills')
VY
withCount('landfills')
SG
$products = Products::query()
->when($request->get('brand'), function ($query, $brands) {
$query->whereHas('brand', function ($query) use ($brands) {
$query->whereIn('name', $brands);
});
})
->when($request->get('sezon'), function ($query, $sezons) {
$qyery->whereIn('sezon', $sezons);
})
->get();
И
$products = Products::query()
->when($request->get('brand'), function ($query, $brands) {
$query->whereHas('brand', function ($query) use ($brands) {
$query->whereIn('name', $brands);
});
})
->when($request->get('sezon'), function ($query, $sezons) {
$qyery->whereIn('sezon', $sezons);
})
->get();
AK
И
public function products(){
return $this->hasMany('App\Products', 'brand_id');
}
AK
public function products(){
return $this->hasMany('App\Products', 'brand_id');
}
Products
И
Products
public function brand(){
return $this->belongsTo('App\Brands', 'id');
}
AK
public function brand(){
return $this->belongsTo('App\Brands', 'id');
}
V
AK
public function brand(){
return $this->belongsTo('App\Brands', 'id');
}
И
AK
И
И
$products = Products::query()
->when($request->get('brand'), function ($query, $brands) {
$query->whereHas('brand', function ($query) use ($brands) {
$query->whereIn('name', $brands);
});
})
->when($request->get('sezon'), function ($query, $sezons) {
$qyery->whereIn('sezon', $sezons);
})
->get();
AK
И
VY
public function landfills($direction = 'asc')
{
return $this->hasMany(ReportTko\Zone\Landfill::class)
->orderBy('id', $direction);
}