问题
Employee::has("tags")->orHas("Categories")->where("employeeName","LIKE","seo%")->get();
I have two belongsToMany relationship which is tags and Categories. Mutiple has clause works unless I put where clause after.
How can I use has clause with where ??
I need help !!
回答1:
You probably want something like this:
Employee::where(function($q) {
$q->has("tags")->orHas("Categories");
})->where("employeeName","LIKE","seo%")->get();
because you need to have brackets in your query to get what you expect
来源:https://stackoverflow.com/questions/35513518/laravel-eloquent-multiple-has-and-where-clause