¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -12,20 +12,24 @@ class Attribute extends Model
{
use Translatable, Sluggable;
/**
* The attributes that are translatable.
*
* @var array
*/
public $translatedAttributes = ['name'];
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = ['translations'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['attribute_set_id', 'slug', 'is_filterable'];
/**
* The attributes that should be cast to native types.
*
@@ -34,14 +38,6 @@ class Attribute extends Model
protected $casts = [
'is_filterable' => 'boolean',
];
/**
* The attributes that are translatable.
*
* @var array
*/
public $translatedAttributes = ['name'];
/**
* The attribute that will be slugged.
*
@@ -49,6 +45,7 @@ class Attribute extends Model
*/
protected $slugAttribute = 'name';
/**
* Perform any actions required after the model boots.
*
@@ -61,25 +58,6 @@ class Attribute extends Model
});
}
public function attributeSet()
{
return $this->belongsTo(AttributeSet::class);
}
public function categories()
{
return $this->belongsToMany(Category::class, 'attribute_categories');
}
public function values()
{
return $this->hasMany(AttributeValue::class)->orderBy('position');
}
public function table()
{
return new AttributeTable($this->with('attributeSet'));
}
public function saveRelations(array $attributes)
{
@@ -87,6 +65,13 @@ class Attribute extends Model
$this->saveValues(array_get($attributes, 'values', []));
}
public function categories()
{
return $this->belongsToMany(Category::class, 'attribute_categories');
}
public function saveValues($values = [])
{
$ids = $this->getDeleteCandidates($values);
@@ -103,6 +88,25 @@ class Attribute extends Model
}
}
public function values()
{
return $this->hasMany(AttributeValue::class)->orderBy('position');
}
public function attributeSet()
{
return $this->belongsTo(AttributeSet::class);
}
public function table()
{
return new AttributeTable($this->with('attributeSet'));
}
private function getDeleteCandidates($values = [])
{
return $this->values()