<?php

namespace App\Models\Shop;

use App\Traits\Model\HasComments;
use Illuminate\Database\Eloquent\Model;

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);
    }
}
