<?php
namespace App\Model\Table;

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

/**
 * Apresults Model
 *
 * @method \App\Model\Entity\Apresult get($primaryKey, $options = [])
 * @method \App\Model\Entity\Apresult newEntity($data = null, array $options = [])
 * @method \App\Model\Entity\Apresult[] newEntities(array $data, array $options = [])
 * @method \App\Model\Entity\Apresult|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\Apresult patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
 * @method \App\Model\Entity\Apresult[] patchEntities($entities, array $data, array $options = [])
 * @method \App\Model\Entity\Apresult findOrCreate($search, callable $callback = null, $options = [])
 *
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
 */
class ApresultsTable extends Table
{

    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('apresults');

        $this->addBehavior('Timestamp');
    }

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

        $validator
            ->dateTime('erzeugungsdatum')
            ->allowEmpty('erzeugungsdatum');

        $validator
            ->decimal('anzahl')
            ->allowEmpty('anzahl');

        $validator
            ->integer('id')
            ->requirePresence('id', 'create')
            ->notEmpty('id');

        $validator
            ->requirePresence('aptype', 'create')
            ->notEmpty('aptype');

        $validator
            ->requirePresence('snr', 'create')
            ->notEmpty('snr');

        $validator
            ->integer('apcount')
            ->requirePresence('apcount', 'create')
            ->notEmpty('apcount');

        return $validator;
    }
}
