Q:

Comparing values in a model cakephp

excuse me , I m still new to cakephp.
What I want to make a custom function to compare between 2 values, but I want to send the values as parameters to the function.
here's my model :
<?php
     App::uses('AppModel', 'Model');
    class PayGrade extends AppModel 
    {
   public $displayField = 'id';

public $validate = array(
    'id' => array(
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
        'uuid' => array(
            'rule' => array('uuid'),
        ),
        'numeric' => array(
            'rule' => array('numeric'),
        ),
    ),
    'Salary_max' => array(
        'numeric' => array(
            'rule' => array('numeric'),
        ),
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
    ),
    'Salary_min' => array(
        'numeric' => array(
            'rule' => array('numeric'),
        ),
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
    ),
    'Currency' => array(
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
    ),
    'eval_pts_from' => array(
        'numeric' => array(
            'rule' => array('numeric'),
        ),
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
    ),
    'eval_pts_to' => array(
        'numeric' => array(
            'rule' => array('numeric'),
        ),
        'notEmpty' => array(
            'rule' => array('notEmpty'),
        ),
    ),
);
    function compareVals($min,$max)
    {
        if($min >= $max)
        {
            return false;
        }
        else 
        {
            return true;
        }
    }
public $hasMany = array(
    'Jobs_levels' => array(
        'className' => 'Jobs_levels',
        'foreignKey' => 'Pay_grades_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

}
I want to compare (eval_pts_to with eval_pts_from) and (Salary_max with Salary_min).
I v searched but found some functions that calls the variables from inside of the function, which means I ll have to create 2 functions one for eval_points and the other for the salary
Thank you in advance

A:

Some code can explain You:
public function validationComparisonField($check, $other_field) {
    if ($this->data[$this->alias][$other_field] > $check[key($check)])) {
        return true; // passed
    }

    return false; // not passed
}

You can always get data from $this->data
Validation rules:
'Salary_max' => array(
        'numeric' => array(
            'rule' => array('validationComparisonField', 'salary_min'),
        ),

