Files
opensem/app/Models/Shop/ArticleAttribute.php
Ludovic CANDELLIER ef791fbcf2 Fix on new model
2020-07-26 23:48:12 +02:00

36 lines
734 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', 'article_attribute_value_id');
}
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);
}
}