Undefined property: Illuminate\Database\Eloquent\Builder

ぃ、小莉子 提交于 2019-12-24 05:53:00

问题


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;

and the result is :

Undefined property: Illuminate\Database\Eloquent\Builder::$name

Someone help me pls :(


回答1:


You need to finish the query with get() or first(). In your case probably:

States_Images::where('id_state', $id)->first();


来源:https://stackoverflow.com/questions/37144564/undefined-property-illuminate-database-eloquent-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!