*/ protected $fillable = [ 'name', ]; /** * Get the translations for this attribute. */ public function translations(): HasMany { return $this->hasMany(StockAttributesTranslation::class, 'stock_attributes_id'); } /** * Get the values for this attribute. */ public function values(): HasMany { return $this->hasMany(StockAttributeValues::class, 'stock_attribute_id'); } /** * Get the translation for a specific language. * * @param int $languageId * @return \Illuminate\Database\Eloquent\Model|null */ public function getTranslation(int $languageId) { return $this->translations()->where('language_id', $languageId)->first(); } }