Files
opensem/app/Models/Shop/PriceGeneric.php
Ludovic CANDELLIER 083d358fbd Mise à jour
2021-03-21 23:26:53 +01:00

40 lines
873 B
PHP

<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Znck\Eloquent\Traits\BelongsToThrough;
class PriceGeneric extends Model
{
use BelongsToThrough;
protected $guarded = ['id'];
protected $table = 'shop_price_generics';
public function category()
{
return $this->hasOne('App\Models\Shop\PriceGenericCategory','id','category_id');
}
public function prices()
{
return $this->hasMany('App\Models\Shop\PriceGenericValue','price_generic_id')->whereNotNull('price_generic_id');
}
public function priceByUnit()
{
return $this->hasOne('App\Models\Shop\PriceGenericValue')->orderBy('quantity','asc');
}
public function articles()
{
return $this->hasManyThrough('App\Models\Shop\Article','App\Models\Shop\Price');
}
public function scopeByCategory($query, $id)
{
return $query->where('category_id', $id);
}
}