<?php
namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
 * ReportFormatVariableValues Model

 * @method \App\Model\Entity\ReportFormatVariableValue get($primaryKey, $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue newEntity($data = null, array $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue[] newEntities(array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue[] patchEntities($entities, array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatVariableValue findOrCreate($search, callable $callback = null, $options = [])
 */
class ReportFormatVariableValuesTable extends Table
{
    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('report_format_variable_values');
        $this->setPrimaryKey('id');

        $this->belongsTo('ReportFormats');
        $this->belongsTo('ReportFormatVariables');
        $this->belongsTo('ReportFormatGenerationHistories');

    }

    /**
     * Default validation rules.
     *
     * @param \Cake\Validation\Validator $validator Validator instance.
     * @return \Cake\Validation\Validator
     */
    public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmptyString('id', null, 'create');

        $validator
            ->integer('report_format_id')
            ->requirePresence('report_format_id', 'create')
            ->notEmptyString('report_format_id');

        $validator
            ->integer('report_format_variable_id')
            ->requirePresence('report_format_variable_id', 'create')
            ->notEmptyString('report_format_variable_id');

        $validator
            ->integer('report_format_generation_history_id')
            ->requirePresence('report_format_generation_history_id', 'create')
            ->notEmptyString('report_format_generation_history_id');

        $validator
            ->scalar('value')
            ->maxLength('value', 100)
            ->requirePresence('value', 'create')
            ->notEmptyString('value');

        $validator
            ->integer('status');

        $validator
            ->integer('created_by_id')
            ->allowEmptyString('created_by_id');

        $validator
            ->integer('updated_by_id')
            ->allowEmptyString('updated_by_id');

        $validator
            ->dateTime('created_at')
            ->allowEmptyDateTime('created_at');

        $validator
            ->dateTime('updated_at')
            ->allowEmptyDateTime('updated_at');

        return $validator;
    }
}
