方法或不存在的地方.Laravel 5.3 [英] Method orWhere does not exist. Laravel 5.3

查看:48
本文介绍了方法或不存在的地方.Laravel 5.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BadMethodCallException:方法or不存在的地方.

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();

如果我在没有"orWhere"的情况下尝试使用,如果使用它,则会引发错误.有人知道哪里出了错吗?

If I try without "orWhere" works, if I use it, throws an Error. Someone knows where is the mistake?

推荐答案

您正尝试在集合上使用 orWhere ,这就是为什么它向您显示错误的原因.您应该在这样的模型上使用此模型(将 Category 作为模型):

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();

请参阅Laravel文档以获取 orWhere()

希望这会有所帮助!

这篇关于方法或不存在的地方.Laravel 5.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆