vendredi 22 juin 2018

How to use whereIn() when column names don't match?

I am trying to use whereIn() to find records who have 'prov' that can be found in this array;

array:3 [▼
  0 => array:6 [▼
"id" => 1
"contest_id" => 1
"contest_zone_id" => 1
"province" => "ON"
"created_at" => "2018-06-20 13:37:45"
"updated_at" => "2018-06-20 13:37:45"
  ]
  1 => array:6 [▼
"id" => 2
"contest_id" => 1
"contest_zone_id" => 1
"province" => "SK"
"created_at" => "2018-06-20 13:37:45"
"updated_at" => "2018-06-20 13:37:45"
  ]
  2 => array:6 [▼
"id" => 3
"contest_id" => 1
"contest_zone_id" => 1
"province" => "NB"
"created_at" => "2018-06-20 13:37:45"
"updated_at" => "2018-06-20 13:37:45"
]
]

So I can do this;

->whereIn('prov', $provinces)

However, in my 2 tables 'prov' and 'province' aren't the same so it's not working. Is there a way to explicitly declare which columns I want to compare?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire