I seem to have a hard time understanding how to properly query as the logic of it gets confused as I try to use different operators.

Anyways, I have three tables: Customer, Cpe, Equipment. I want data from equipment but in order to do that, I must use Customer to relate to Cpe, then relate that table to Equipment.

The relationships are as follows:

Customer has many Cpe customerid > customerid
Cpe has one Equipment equipid > equipid

There is nothing relating Customer and Equipment except the Cpe table.

I specifically want to select the Customer.customerid, Customer.name, Equipment.nickname, Customer.customerstatus, Customer.installationdate. But I also want to only select the customers who have Equipment.nickname LIKE %SIM%. So what I have is:

```
$baicell_customers = Customer::with('Cpe')
->with('Cpe.Equipment')
->select('Customer.customerid', 'Customer.name', 
'Equipment.nickname', 'Customer.customerstatus', 
'Customer.installationdate' => function($query){
$query->where('Equipment.nickname', 'LIKE', '%SIM%');
})
->orderBy('Customer.name', 'asc');
->get();

```

But this gets me nothing. I'm not great at the whole relating one table to another and to throw in the fact that I have to use a related table to get info from another is just bonkers for me so any help would be greatly appreciated.