<?php
namespace App\Model\Table;

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


class ItemsTable extends Table
{

    
    public function initialize(array $config)
    {
        parent::initialize($config);
        
        //table name
        $this->table('items');
        $this->displayField('name');
        $this->primaryKey('id');
   
    }
    
    //validator method
    public function validationDefault(Validator $validator)
    {
     
        $validator
            ->requirePresence('name', 'create')
            ->notEmpty('name');
        
        $validator
            ->numeric('value')
            ->notEmpty('value');
        
        $validator
            ->notEmpty('type');
         
        $validator
            ->allowEmpty('description');

        return $validator;
    }

}


