【发布时间】:2021-04-03 22:22:29
【问题描述】:
我想在表格中显示每个实体的名称,但它返回了我
此集合实例上不存在属性 [名称]。
我的控制器
$users = User::with('pearls')->latest()->get();
index.blade.php
<thead>
<tr>
<th scope="col">SL No</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
@foreach($users as $user)
<th>{{ $user->pearls->name}}</th>
@endforeach
<th scope="col">Actions</th>
</tr>
</thead>
【问题讨论】:
-
您的问题不完整,请显示您的数据库架构,您可以使用 dd($users) 检查自己,然后检查珍珠是否具有名称属性
标签: php html database laravel relationship