试图显示两个表中的数据并收到上述错误消息,有人可以帮助翻译此错误消息吗?
这是控制器

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">&nbsp;</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变量,页面就会显示良好。可能是问题所在,因为我不了解列表中的错误消息

最佳答案

您传递的是整个$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>

10-07 21:03