Files
opensem/app/Models/Shop/Price.php
2021-03-22 00:47:44 +01:00

55 lines
994 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('App\Models\Shop\Article');
}
public function article_family()
{
return $this->belongsTo('App\Models\Shop\ArticleFamily');
}
public function generic()
{
return $this->belongsTo('App\Models\Shop\PriceGeneric', 'price_generic_id');
}
public function generic_prices()
{
}
public function scopeByArticle($query, $id)
{
return $query->where('article_id', $id);
}
public function scopeByArticleFamily($query, $id)
{
return $query->where('article_family_id', $id);
}
public function scopeGeneric($query)
{
return $query->whereNotNull('price_generic_id');
}
public function scopeNotGeneric($query)
{
return $query->whereNull('price_generic_id');
}
}