<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PackageDescription extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'title',
        'slug',
        'meta_description',
        'description',
        'keywords',
        'meta',
        'package_id',
        'language_id',
    ];

    /**
     * descrips how the model cast the field value
     */
    protected $casts = ['meta' => 'array'];

    /**
     * Return package pickup place
     * @return string
     */
    public function getPickupAttribute(): ?string
    {
        return $this->meta ? $this->meta['pickup'] ?? null: null;
    }

    /**
     * Return package Price Include Features
     * @return array
     */
    public function getPriceIncludeAttribute(): array
    {
        return $this->meta ? $this->meta['price_include'] ?? []: [];
    }

    /**
     * Return package Price Exclude
     * @return array
     */
    public function getPriceExcludeAttribute(): array
    {
        return $this->meta ? $this->meta['price_exclude'] ?? []: [];
    }

    /**
     * Return package Itinerary
     * @return array
     */
    public function getItineraryAttribute(): array
    {
        return $this->meta ? $this->meta['itinerary'] ?? []: [];
    }

    /**
     * Return package Faq
     * @return array
     */
    public function getFaqAttribute(): array
    {
        return $this->meta ? $this->meta['faq'] ?? []: [];
    }

    /**
     * Return package for description
     * @return BelongsTo
     */
    public function package() :BelongsTo
    {
        return $this->belongsTo(Package::class);
    }
}
