<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Package extends Model
{
    protected $fillable = [
        'package_type',
        'house_type',
        'price_per_person',
        'package_date',
        'departure_city',
        'arrival_city',
        'rally_point_info',
        'image',
        'status',
    ];

    protected $casts = ['rally_point_info' => 'array'];

    public function descriptions() :HasMany
    {
        return $this->hasMany(PackageDescription::class);
    }

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

    public function reservations()
    {
        return $this->hasMany(PackageReservation::class);
    }
}
