35 lines
720 B
PHP
35 lines
720 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
|
|
class Price extends Model
|
|
{
|
|
use HasRelationships;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_prices';
|
|
|
|
public function article()
|
|
{
|
|
return $this->belongsTo(Article::class);
|
|
}
|
|
|
|
public function article_family()
|
|
{
|
|
return $this->belongsTo(ArticleNature::class);
|
|
}
|
|
|
|
public function scopeByArticle($query, $id)
|
|
{
|
|
return $query->where($this->table . '.article_id', $id);
|
|
}
|
|
|
|
public function scopeByArticleNature($query, $id)
|
|
{
|
|
return $query->where($this->table . '.article_family_id', $id);
|
|
}
|
|
}
|