gpt4 book ai didi

Trying to get the propery of object but it is returning unexpected error in laravel?(正在尝试获取对象的属性,但在LARLAVEL中返回意外错误?)

转载 作者:bug小助手 更新时间:2023-10-28 22:26:49 24 4
gpt4 key购买 nike



I have create a laravel object as per the documentation. Though when i am trying to get the value from it, it is throwing the error.

我已经按照文档创建了一个laravel对象。不过,当我试图从它获得值时,它抛出了错误。


Here is a sample code

以下是一个示例代码


$user = USER::findOrFail(2990);

$USER=用户::findOrFail(2990);


print_r($user);

Print_r($USER);


This is throwing error. Please help me what i am doing wrong?

这简直是大错特错。请帮帮我,我哪里做错了?


更多回答

Divert your attention to USER method. Part “orFail” hints at error if nothing found.

将您的注意力转移到用户方法上。如果什么都没有找到,部件“orFail”就会提示错误。

优秀答案推荐

Its quite hard to answer this without an exact error messsage.

在没有准确的错误消息的情况下,很难回答这个问题。


This could be a case sensitivity issue. In Laravel, class names should be written in title case, but it seems you are using uppercase for "USER" instead of "User."

这可能是一个区分大小写的问题。在Laravel中,类名应该以标题大小写形式书写,但似乎您使用的是大写的“User”而不是“User”。


$user = User::findOrFail(2990);
print_r($user);

It is also possible that it's just that no user with ID 2990 exists. And that throws an error. could you recheck if such a user exists?

也有可能只是不存在ID为2990的用户。这就抛出了一个错误。您能重新检查一下这样的用户是否存在吗?


Please upvode and accept if it helps :)

如果有帮助,请支持并接受:)



first of all check in your database ( User Table ) what is the value of id = 2990

首先检查您的数据库(用户表),id=2990的值是多少


to print your variable try to use dd($user)

要打印变量,请尝试使用dd($USER)


更多回答

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

就目前所写的,你的答案还不清楚。请编辑以添加其他详细信息,以帮助其他人理解这是如何解决所问问题的。你可以在帮助中心找到更多关于如何写好答案的信息。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com