Files
opensem/app/Models/Shop/Variation.php
Ludovic CANDELLIER f5716c6530 Add filters
2021-11-01 23:42:53 +01:00

36 lines
659 B
PHP

<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use App\Traits\Model\HasComments;
class Variation extends Model
{
use HasComments;
protected $guarded = ['id'];
protected $table = 'shop_variations';
public function package()
{
return $this->belongsTo(Package::class);
}
public function unity()
{
return $this->belongsTo(Unity::class);
}
public function offers()
{
return $this->hasMany(Offer::class);
}
public function scopeByPackage($query, $package_id)
{
return $query->where($this->table . '.package_id', $package_id);
}
}