belongsTo(Family::class); } public function species(): HasMany { return $this->hasMany(Specie::class); } public function varieties(): HasManyThrough { return $this->hasManyThrough(Variety::class, Specie::class); } public function scopeByName($query, $name) { return $query->where('name', $name); } }