2

Im trying to do a query where i have multiple conditions (including %LIKE% operator) but can't figure how to do it in Laravel's array way with query builder.

$where = ['category' => $c->id, 'name' => $c->name];
$q = Store::where($where)->get();

That way it would return an array of objects with the equal of the name, not the similar matches. Is it possible to do a %LIKE% search in that way?

1 Answer 1

2

You should chain them like this:

DB::table('your-table-name')
    ->where('category','=','$c->id')
    ->where('name','=','$c->name')
    ->where('email', 'LIKE', '%test%')
    ->get();
Sign up to request clarification or add additional context in comments.

1 Comment

Somehow i read in docs it should'nt be this way, but it is, thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.