belongsTo('App\Models\Shop\ArticleAttributeFamily'); } public function attributes() { return $this->hasMany('App\Models\Shop\ArticleAttribute'); } public function articles() { return $this->hasMany('App\Models\Shop\ArticleAttribute')->groupBy('article_id'); } public function scopeByFamily($query, $id) { return $query->where('article_attribute_family_id', $id); } }