49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class StockAttributes extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
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();
|
|
}
|
|
}
|