このクエリの構文が正しいとは言えません。 Product.php
に続いてLaravelには多くのグループがあります
Offer.php
public function user()
{
return $this->belongsTo('App\User', 'buyer_id');
}
public function product(){
return $this->belongsTo('App\Product');
}
でそう
そしてUser.php
public function offers()
{
return $this->hasMany('App\Offer', 'buyer_id');
}
中:
は基本的に、私はオファーがユーザによって行われている記載されている製品を、持っています
public function offer()
{
return $this->hasMany('App\Offer');
}
私はそれらを作成したユーザーによってオファーをグループ化し、オファーが反対している製品のカテゴリ別にグループ化する必要があります。
誰も私がこれらを正しくグループ化できるアイデアはありますか?
私はよく分かりませんが、https://laravel.com/docs/5.4/eloquent-relationships#has-多くを介して –
私はあなたがこのリンクに従うべきだと思うhttps://softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-efficiently/ –