<?php
/**
 * Class Custom_Fields_Resort
 *
 * @package dvcrs-core
 */

namespace DVCRS\Core;

use \Carbon_Fields\Container;
use \Carbon_Fields\Field;

if ( ! defined( 'ABSPATH' ) ) {
	die();
}

/**
 * Custom_Fields_Resort Class
 */
class Custom_Fields_Resort {

	/**
	 * Custom_Fields_Resort constructor
	 */
	public function __construct() {

		\add_action( 'carbon_fields_register_fields', [ $this, 'register_fields' ] );

	}

	/**
	 * Register custom fields
	 */
	public function register_fields() {

		Container::make( 'post_meta', __( 'Resort Details', 'dvcrs-core' ) )
				->where( 'post_type', '=', 'resort' )
				->add_fields(
					[
						Field::make( 'text', 'subtitle', __( 'Resort Subtitle', 'dvcrs-code' ) )
							->set_width( 50 ),
						Field::make( 'text', 'resort_id', __( 'Resort ID', 'dvcrs-code' ) )
							->set_help_text( __( 'DVCRS API: resortId', 'dvcrs' ) )
							->set_width( 25 ),
						Field::make( 'select', 'type', __( 'Resort Type', 'dvcrs-code' ) )
							->add_options( array(
								'resort' => 'Resort',
								'vacation-home' => 'Vacation Home',
							) )
							->set_width( 25 ),
						Field::make( 'text', 'headline', __( 'Resort Details Headline', 'dvcrs-core' ) ),
						Field::make( 'rich_text', 'details', __( 'Resort Details', 'dvcrs-code' ) ),
						Field::make( 'rich_text', 'villas', __( 'Villas Available for Rent', 'dvcrs-code' ) ),
						Field::make( 'media_gallery', 'gallery', __( 'Resort  Gallery', 'dvcrs-code' ) )
							->set_type( [ 'image' ] )
							->set_duplicates_allowed( false ),
					]
				);

		Container::make( 'post_meta', __( 'Rooms', 'dvcrs-core' ) )
				->where( 'post_type', '=', 'resort' )
				->add_fields(
					[
						Field::make( 'complex', 'rooms' )
						->add_fields(
							'room',
							[
								Field::make( 'text', 'title', __( 'Title', 'dvcrs-code' ) )
									->set_width( 50 ),
								Field::make( 'text', 'room_id', __( 'Room ID', 'dvcrs-code' ) )
									->set_help_text( __( 'DVCRS API: roomId', 'dvcrs' ) )
									->set_width( 50 ),
								Field::make( 'rich_text', 'description', __( 'Description', 'dvcrs-code' ) ),
								Field::make( 'textarea', 'matterport', __( 'Matterport Code', 'dvcrs-code' ) ),
								Field::make( 'image', 'floorplan', __( 'Floor Plan', 'dvcrs-code' ) )
									->set_type( [ 'image' ] ),
							]
						),
					]
				);

	}
}

new Custom_Fields_Resort();
