<?php

namespace App\Models;

class PropertyChannelMapping extends BaseModel
{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'property_channel_mapping';
    protected $appends = [];

    const CREATED_AT = 'created_at';
    const UPDATED_AT = 'updated_at';

    protected $dateFormat = 'U';
    protected $guarded = [];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [];


    public function property()
    {
        return $this->hasOne("App\Models\Property",   'id', 'property_id')->select(['id' , 'name']);
    }

    public function channel()
    {
        return $this->hasOne("App\Models\PropertyChannel",   'id', 'channel_id')->select(['id', 'parent_id', 'token','name', 'official_name', 'description', 'channel_category_id', 'country_code', 'country_code_group', 'currency_code', 'default_currency', 'logo', 'address', 'zip_code', 'email', 'phone', 'phone2', 'fax', 'contact', 'status']);
    }

    public function channelBookingType()
    {
        return $this->hasOne("App\Models\PropertyBookingType",   'id', 'property_booking_type_id')->select(['id', 'name', 'language_key', 'code', 'status']);
    }

    public function channelAvailabilityType()
    {
        return $this->hasOne("App\Models\PropertyAvailabilityType",   'id', 'property_availability_type_id')->select(['id', 'name', 'language_key', 'code', 'status']);
    }

    public function channelRoomPricingType()
    {
        return $this->hasOne("App\Models\PropertyRoomPricingType",   'id', 'property_room_pricing_type_id')->select(['id', 'name', 'language_key', 'code', 'status']);
    }

    public function channelBookingPaymentType()
    {
        return $this->hasMany("App\Models\PropertyChannelBookingPaymentSetup",   'property_channel_mapping_id', 'id')->select(['id', 'property_channel_mapping_id', 'payment_type_id', 'cancellation_policy', 'is_affected_price', 'is_get_payment_data','action_type', 'value_type', 'value', 'is_selected', 'status']);
    }

    public function channelContact()
    {
        return $this->hasMany("App\Models\PropertyChannelContact",   'property_channel_mapping_id', 'id')->select(['id', 'property_channel_mapping_id','name', 'email', 'status']);
    }


    public function channelTax()
    {
        return $this->hasOne("App\Models\PropertyChannelTax",   'id', 'channel_tax_id')->select(['id', 'name', 'language_key', 'code', 'status']);
    }

    public function currency()
    {
        return $this->hasOne("App\Models\Currency",   'code', 'currency_code')->select(['id', 'code', 'symbol', 'name', 'language_key', 'status']);
    }
}
