36 lines
704 B
PHP
36 lines
704 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ArticleAttribute extends Model
|
|
{
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_article_attributes';
|
|
|
|
public function article()
|
|
{
|
|
return $this->belongsTo('App\Models\Shop\Article');
|
|
}
|
|
|
|
public function attribute_value()
|
|
{
|
|
return $this->belongsTo('App\Models\Shop\ArticleAttributeValue');
|
|
}
|
|
|
|
public function prices()
|
|
{
|
|
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
|
}
|
|
|
|
public function scopeByArticle($query, $id)
|
|
{
|
|
return $query->where('article_id', $id);
|
|
}
|
|
|
|
public function scopeByAttributeValue($query, $id)
|
|
{
|
|
return $query->where('attribute_value_id', $id);
|
|
}
|
|
} |