<?php

class ContactLog extends AppModel{
    
    public $useTable="contact_logs";
    public $validationDomain = 'validation';
    public $actsAs = array('search-master.Searchable');
    public $belongsTo = array(
            'User' => array(
                'className' => 'User',
                'foreignKey' => 'user_id'
            ),'Category','Location'
    );
    public $filterArgs = array(
        'category_id' => array('field'=>'ContactLog.category_id'),
        'cname' => array('type'=>'like','field'=>array(
            'ContactLog.name','ContactLog.phone'
        ))
    );
    
    public $validate = array(
        'name'=>array(
            'alphaNumeric'=>array(
                'rule'=>'alphaNumericCustom',
                'required'=>true,'allowEmpty'=>false,'message'=>'Only letters and numbers allowed'
            )
        ),
        'direction'=>array(
            'alphaNumeric'=>array(
                'rule'=>'alphaNumericCustom',
                'required'=>true,'allowEmpty'=>false,'message'=>'Only letters and numbers allowed'
            )
        ),
        'location_id'=>array('numeric'=>array('rule'=>'numeric','message'=>'Only Number','allowEmpty'=>false,'required'=>true)),
        'category_id'=>array('numeric'=>array('rule'=>'numeric','message'=>'Only Number','allowEmpty'=>false,'required'=>true)),
        'phone'=>array('numeric'=>array('rule'=>'numeric','required'=>true,'allowEmpty'=>false,'message'=>'Only numbers allowed')),
        'duration'=>array('numeric'=>array('rule'=>'numeric','required'=>true,'allowEmpty'=>false,'message'=>'Only numbers allowed'))
    );
}