35 lines
750 B
PHP
35 lines
750 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Znck\Eloquent\Traits\BelongsToThrough;
|
|
|
|
class ArticlePrice extends Model
|
|
{
|
|
use BelongsToThrough;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_article_prices';
|
|
|
|
public function price()
|
|
{
|
|
return $this->hasOne('App\Models\Price');
|
|
}
|
|
|
|
public function article_family()
|
|
{
|
|
return $this->belongsTo('App\Models\ArticleNature');
|
|
}
|
|
|
|
public function scopeByQuantity($query, $quantity)
|
|
{
|
|
return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first();
|
|
}
|
|
|
|
public function scopeByFamily($query, $id)
|
|
{
|
|
return $query->where('article_family_value_id', $id);
|
|
}
|
|
}
|