umutcankarce İlişki isimlendirmelerine dikkat edin:
Product
public function brand(): BelongsTo
{
return $this->belongsTo(Brand::class, 'brand_id');
}
Brand
public function products(): HasMany
{
return $this->hasMany(Product::class, 'brand_id');
}
Sorguda bir problem göremedim. Tüm ürünleri çektiğinize göre şöyle de yapabilirsiniz:
Brand
public function activeProducts(): HasMany
{
return $this->hasMany(Product::class, 'brand_id')
->where('status', 'active')
->orderBy('id');
}
$brand = Brand::with('activeProducts')
->findOrFail(Crypt::decrypt($id));
return view('frontend.vendors.list.total_product', compact('brand'));
{{ $brand->name }}
@foreach($brand->activeProducts as $product)
{{ $product->name }}
@endforeach