Can the first argument of Laravel updateOrInsert be used as OR instead of pair the values

Viewed 33

From Laravel Docs:

The updateOrInsert method will attempt to locate a matching database record using the first argument's column and value pairs.

DB::table('users')
->updateOrInsert(
    ['email' => 'john@example.com', 'name' => 'John'],
    ['votes' => '2']
);

Would it be possible instead of checking both records to be true at the same time such as 'email' => 'john@example.com' and 'name' => 'John' we check only one such 'email' => 'john@example.com' OR 'name' => 'John'

Something like this which is not possible (or i don't know how)

 DB::table('users')
->updateOrInsert(
    ['email' => 'john@example.com','OR', 'name' => 'John'],
    ['votes' => '2']
);

Is this something that can be done some how?

1 Answers

Short aswer: no

Accordingly to the code, there's only one where, which is expecting an array of attributes, so you can't do an OR clause here.

Related