<?php

namespace App\Core\Validator\PropertyRoomRatePrice;

use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Translation\Translator;

use App\Core\Validator\BaseValidator;

use Exception;

class PropertyRoomRatePriceBulkInsertValidator extends BaseValidator
{


    private $updateTypes ;
    private $includeDays;

    public function __construct
    (


        Translator $translator,
        Container $container
    )
    {
        parent::__construct($translator, $container);
        $this->updateTypes = ["rate", "minstay", "maxstay", "stopsell", "bookingonrequest","rate_stop_sell","min_stay","quick_pricing"];
        $this->includeDays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
    }

    public function rules($params = null)
    {
        return
            [
                'property_id' => 'required|numeric',
                'update_type' => 'required|in:'.implode(',', $this->updateTypes),
                'value' => 'required|numeric',
                'start_date' => 'required|date_format:Y-m-d',
                'end_date' => 'required|date_format:Y-m-d',
                'availability_type_id' => 'required|in:1,2,3',
                'channel_id' => 'required|integer',

                'room_rates' => 'required|array',
                'room_rates.*.room_id' => 'required|numeric',
                'room_rates.*.room_rate_mapping_id' => 'required|array',
                'include_days.*' => 'required|in:'.implode(',', $this->includeDays),
            ];


    }

    public function messages()
    {
        $thisMessages = [];
        return array_merge(parent::messages() , $thisMessages);
    }


    public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
    {
        return $this->make($params, $this->rules($params), $this->messages());
    }

}
