Eloquent 预加载报属性不存在问题?
//预加载
$user = User::with('hasManyPost')->get();
foreach ($user as $value){
echo $value->hasManyPost->title;
//var_dump($value->hasManyPost);
}
这段代码运行后会报Property [title] does not exist on this collection instance. `$value->hasManyPost`返回的不就是object吗,Post表内是有title列的。为啥会提示没有title呢
推荐文章: