I have a custom module to store customer relationship, with database structure like this:
|entity_id|first_customer|second_customer|
entity_id => the relationship id
first_customer => customer id
second_customer => customer id
if the customer has a relationship with another customer, each of their customer id will fill first_customer and second_customer, i want to check if the relationship already exist for given 2 customer id, for example
+---------+--------------+---------------+
|entity_id|first_customer|second_customer|
+---------+--------------+---------------+
| 1 | 1 | 35 |
| 2 | 3 | 1 |
| 2 | 4 | 2 |
| 2 | 2 | 6 |
+---------+--------------+---------------+
public function validate($customerIdA,$customerIdB){
$friend = $this->friendFactory->create()->getCollection()
->addFieldToFilter(????)->getFirstItem();
if(!empty($friend->getId())) return true;
else return false;
}
//the order of the parameter is not gonna be the order of the filter
$this->validate(1,35); //true
$this->validate(35,1); //true
$this->validate(1,2); //false
$this->validate(1,3); //true
$this->validate(4,2); //true