<?php

namespace Modules\Package\Models;

use Modules\Package\Models\PackageDescription;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class Package extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'cost','cost_discount','length'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function currentDescription() :HasOne
    {
        return $this->hasOne(PackageDescription::class)->where('language_id', currentLanguage()->id);
    }

    public function getPriceAttribute()
    {
        return !is_null($this->cost_discount) ? $this->cost_discount : $this->cost;
    }
}
