未定义属性:Illuminate \ Database \ Eloquent \ Builder

时间:2016-05-10 16:51:15

标签: eloquent echo builder

这件事发生在我身上。我的代码如下:

$state_image =States_Images::where('id_state', $id);
echo $delete_path=$state_image->name;

结果是:

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

有人帮我说:(

1 个答案:

答案 0 :(得分:5)

您需要使用get()或first()完成查询。在你的情况下可能:

lists = [Everton, Liverpool, Villa]
queryset = Betting.objects.filter(matches__in=list)