Where In multiple columns

Posted 9 months ago by ARCANEDEV

I have a table with something like this:

  - id
  - morphable_type
  - morphable_id

And i want to query this table with the Eloquent method whereIn(...):

$values = [
    ['type_a', 1],
    ['type_a', 2],
    ['type_b', 1],
    ['type_c', 1],

$dummies = Dummy::whereIn(['morphable_type', 'morphable_id'], $values)->get();

Any one has any idea how to achieve that ?

Works fine with a direct SQL but not with Eloquent class.

SELECT * FROM `dummy` 
WHERE (dummy.morphable_type, dummy.morphable_id) 
IN (('type_a', 1), ('type_a', 2), ('type_b', 1), ('type_c', 1))

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.