jeudi 12 octobre 2017

Laravel: orWhereHas() disables where()?

I want to get all users who have a related row in the table addresses or in the table institutes. In addition, I want that modeIN should be equal to MT. I thought the following query would do that, but it does not work:

$users = User::whereHas('addresses')
          ->orWhereHas('institutes')
          ->where('modeIN', '=', 'MT')
          ->get()
          ->pluck('modeIN');

dd($users);

There are still users listed where modeIN is not equal to MT. Why is this happening and how can I fix it?

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire