laravel - production.ERROR:从空值创建默认对象 {"exception":"[object]
问题描述
我收到错误生产。错误:
从空值创建默认对象 {"exception":"[object]
但我无法检测到错误。
$data = Deposit::where('status',0)->where('wallet', $request->address)->orderBy('id', 'DESC')->first();
if ($request->status>=1 || $request->status==2)
{
$data = Deposit::where('status',0)->where('wallet', $request->address)->orderBy('id', 'DESC')->first();
$data->amount = $request->amount; // Here IS ERROR
$data->status= 1;
$data->update();
}
解决方案
$data
未设置 - 您的查询约束未找到记录并返回null
。然后,您尝试设置值$data->amount
,但由于$data
不存在,因此会出错。
确保您的查询是正确的并加载存在的存款记录,否则设置$data = new Deposit
为创建新记录。
推荐阅读
- svg - Highcharts在svg标记上填充serie的颜色
- reactjs - DashboardMenuItem 活动资源
- list - Haskell 检查整数第一个元素以处理 ID 号
- c++ - 在具有大量输入的 C++ 中使用向量时出现运行时错误
- momentjs - 日期格式无法使用 momentjs
- docker - Kafka Connect,插件路径
- android-mediacodec - 如何解释 MediaCodec 错误消息?
- node.js - 在 AWS lambda 中使用 airtable.js 模块的问题
- firebase - 从 Firestore 加载繁重的文档是否需要很长时间?
- python - 尝试合并几何时的 Geopandas 错误