问题
BadMethodCallException in Macroable.php line 74: Method orWhere does not exist.
$category = $categories->where('Node_ID', (explode('.', $cat{$title_id})[0]))
->orWhere('Node_Path', $cat->{$category_name})
->first();
If I try without "orWhere" works, if I use it, throws an Error. Someone knows where is the mistake?
回答1:
You are trying to use orWhere
on collections, thats why its showing you the error. You should use this on model like this (taking Category
as a Model):
$category = Category::where('Node_ID', (explode('.', $cat{$title_id})[0]))
->orWhere('Node_Path', $cat->{$category_name})
->first();
See Laravel Docs for orWhere()
Hope this helps!
来源:https://stackoverflow.com/questions/40935435/method-orwhere-does-not-exist-laravel-5-3