未定义的属性:Illuminate\数据库\Eloquent\Builder [英] Undefined property: Illuminate\Database\Eloquent\Builder
本文介绍了未定义的属性:Illuminate\数据库\Eloquent\Builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这件事发生在我身上,我有下面的代码:
This strange thing is happening to me.I have the code below :
$state_image =States_Images::where('id_state', $id);
echo $delete_path=$state_image->name;
,结果是:
Undefined property: Illuminate\Database\Eloquent\Builder::$name
有人帮助我:(
推荐答案
您需要使用get()或first()完成查询。在您的情况下,可能是:
You need to finish the query with get() or first(). In your case probably:
States_Images::where('id_state', $id)->first();
这篇关于未定义的属性:Illuminate\数据库\Eloquent\Builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文