【问题标题】:ErrorException (E_ERROR) rawurlencode() expects parameter 1 to be string, object given 'ErrorException (E_ERROR) rawurlencode() 期望参数 1 是字符串,给定对象 '
【发布时间】:2018-11-27 09:58:06
【问题描述】:

ErrorException (E_ERROR) rawurlencode() 期望参数 1 是字符串,给定对象 '

我正在尝试显示两个表中的数据并收到上述错误消息,有人可以帮助翻译此错误消息吗?

这里是控制器

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');

【问题讨论】:

  • 确实,我们无法从远处神奇地读取您的代码。这不是它的工作原理。包括您的代码 sn-ps、错误消息。向我们展示你得到了什么,你已经尝试了什么?
  • 换句话说,取tour

标签: php laravel


【解决方案1】:

此错误消息表明某些内容是通过您的 url 路由的,在这种情况下是从视图中。为了解决这个问题,这段代码

<a href="{{ url('agent/edit_maintenance', $maintenance }}" type="button" class="btn btn-outline btn-success"><i class="ti-pencil"></i></a>

改成

<a href="{{ url('agent/edit_maintenance/'. $maintenance->id }}" type="button" class="btn btn-outline btn-success"><i class="ti-pencil"></i></a>

【讨论】:

    猜你喜欢
    • 2018-11-28
    • 2020-11-22
    • 2021-02-06
    • 1970-01-01
    • 2021-05-07
    • 2018-06-16
    • 2019-09-05
    • 2015-06-27
    • 1970-01-01
    相关资源
    最近更新 更多