尝试显示来自两个表的数据并收到上述错误消息,有人可以帮助翻译此错误消息吗? 这是控制器
public function index()
{
$maintenances = DB::table('tenants')->select('tenants.lastname','tenants.firstname','maintenances.m_status','tenants.designation', 'maintenances.description','maintenances.building_section','maintenances.category','maintenances.reported_date')
->join('maintenances','maintenances.tenants_id','=','tenants.id')
->get();
//dd($maintenances);
return view('agent/maintenance_list', compact('maintenances', 'assetTenants', 'tenants'));
}
并查看
@foreach($maintenances as $maintenance)
<tr>
<td class="text-center">
<div class="checkbox-custom">
<input id="product-01" type="checkbox" value="01">
<label for="product-01" class="pl-0"> </label>
</div>
</td>
<td>{{ $maintenance->designation }} {{ $maintenance->firstname }} {{ $maintenance->lastname }}</td>
<td>{{ $maintenance->category }}</td>
<td>{{ $maintenance->building_section }}</td>
<td>{{ $maintenance->description }}</td>
<td>{{ $maintenance->reported_date }}</td>
<td>{{ $maintenance->m_status }}</td>
<td class="text-center">
<div role="group" aria-label="Basic example" class="btn-group btn-group-sm">
<a href="{{ url('agent/edit_maintenance', $maintenance }}" type="button" class="btn btn-outline btn-success"><i class="ti-pencil"></i></a>
</div>
</td>
</tr>
@endforeach
使用路线
Route::get('maintenance_list', 'MaintenanceController@index')->name('/maintenance_list');
但是,我注意到,一旦我从url编辑按钮中删除$ maintenance变量,页面就会显示出来。可能是什么问题,因为我不理解列表中的错误消息
答案 0 :(得分:0)
您正在传递整个$maintenance
而不是$maintenance->id
,因此object given
错误:
<a href="{{ url('agent/edit_maintenance', $maintenance }}" type="button" class="btn btn-outline btn-success"><i class="ti-pencil"></i></a>