<?php
namespace App\Model\Table;


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

/**
 * PassportDetails Model

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

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

    }

    /**
     * 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('student_id')
            ->requirePresence('student_id', 'create')
            ->notEmptyString('student_id');


        $validator
            ->decimal('living_costs')
            ->requirePresence('living_costs', 'create')
            ->notEmptyString('living_costs');

        $validator
            ->decimal('total_fees')
            ->requirePresence('total_fees', 'create')
            ->notEmptyString('total_fees');

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

        $validator
            ->scalar('visa_type')
            ->allowEmptyString('visa_type');


        $validator
            ->scalar('passport_no')
            ->allowEmptyString('passport_no');

        $validator
            ->scalar('verification_link')
            ->allowEmptyString('verification_link');

        $validator
            ->scalar('verification_code_img_path')
            ->allowEmptyString('verification_code_img_path');

        $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;
    }


}
