I have a table that is hierarchical and i want to say isUnique when the parent_id is the same. I want the below table entries to be possible:
ID, Name, Description, Parent_id
1 , VLAN1, TEST , NULL
2 , VLAN2, TEST2 , NULL
3 , VLAN100, TEST100 , 1
4 , VLAN20, TEST20 , 1
5 , VLAN100, TEST100 , 2
6 , VLAN20, TEST20 , 2
Below is the validation rule:
public $validate = array(
'Vlan' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'required' => true,
),
'uniqueVLAN' => array(
'rule' => 'isUnique',
'message' => 'VLAN already exists'
)
),
'Name' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
'required' => true,
),
'uniqueName' => array(
'rule' => 'isUnique',
'message' => 'Vlan name already exists'
)
),
);
Currently the standard isUnique from what I can see will just check all records don't match, is there a way i can say isUnique where Parent_id = Parent_id?
I cant figure out if I can do this.
Thanks in advance