Laravel : "Object of class stdClass could not be converted to string" 同时将变量传递给闭包
Laravel : "Object of class stdClass could not be converted to string" while pass variable into closure
我收到这样的错误
ErrorException
这是我的 link 索引
<td><a href="{{route('detail_face_to_face', $tm->id)}}">{{$cmface}}</a></td>
这是我的路线
Route::get('/detail_face_to_face/{id}', 'FaceToFaceController@detail')->name('detail_face_to_face');
这是我的控制器
public function detail($id)
{
$xclass = DB::table('face_to_face')->select('Class')->where('id', $id)->first();
$tface = DB::table('tbclass')
->select('tbclass.F_Name','tbclass.Class')
->where('tbclass.Class', $xclass)
->whereNotExists(function ($query) use ($id) {
$query->select('id_user')
->from('absent')
->where([['absent.id_face_to_face', $id],['absent.type_face_to_face', '1'],])
->whereRaw('absent.id_user = tbclass.ID_No');
})
->orderBy('tbclass.F_Name', 'ASC')
->paginate(10);
return view('face_to_face.detail',['tface' => $tface]);
}
这是我的 face_to_face.detail 页面
<table class="table">
<thead style="white-space:nowrap;">
<tr>
<th>No</th>
<th>Name</th>
<th>Class</th>
</tr>
</thead>
<tbody style="white-space:nowrap;">
@if($tface->count()===0)
<tr>
<td class="table-success text-center" colspan="10"><< Data is Empty >></td>
</tr>
@else
@foreach($tface as $no => $tm)
<tr>
<td>{{ ++$no + ($tface->currentPage()-1) * $tface->perPage() }}</td>
<td>{{$tm->F_Name}}</td>
<td>{{$tm->Class}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
{{ $tface->links() }}
如果我单击索引页上的 link,我会收到该错误
有人能帮忙吗???
你能 dd($xclass) 吗?
错误在,->where('tbclass.Class', $xclass)。你可能会做 ->where('tbclass.Class', $xclass->Class)
关注
我收到这样的错误 ErrorException
这是我的 link 索引
<td><a href="{{route('detail_face_to_face', $tm->id)}}">{{$cmface}}</a></td>
这是我的路线
Route::get('/detail_face_to_face/{id}', 'FaceToFaceController@detail')->name('detail_face_to_face');
这是我的控制器
public function detail($id)
{
$xclass = DB::table('face_to_face')->select('Class')->where('id', $id)->first();
$tface = DB::table('tbclass')
->select('tbclass.F_Name','tbclass.Class')
->where('tbclass.Class', $xclass)
->whereNotExists(function ($query) use ($id) {
$query->select('id_user')
->from('absent')
->where([['absent.id_face_to_face', $id],['absent.type_face_to_face', '1'],])
->whereRaw('absent.id_user = tbclass.ID_No');
})
->orderBy('tbclass.F_Name', 'ASC')
->paginate(10);
return view('face_to_face.detail',['tface' => $tface]);
}
这是我的 face_to_face.detail 页面
<table class="table">
<thead style="white-space:nowrap;">
<tr>
<th>No</th>
<th>Name</th>
<th>Class</th>
</tr>
</thead>
<tbody style="white-space:nowrap;">
@if($tface->count()===0)
<tr>
<td class="table-success text-center" colspan="10"><< Data is Empty >></td>
</tr>
@else
@foreach($tface as $no => $tm)
<tr>
<td>{{ ++$no + ($tface->currentPage()-1) * $tface->perPage() }}</td>
<td>{{$tm->F_Name}}</td>
<td>{{$tm->Class}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
{{ $tface->links() }}
如果我单击索引页上的 link,我会收到该错误
有人能帮忙吗???
你能 dd($xclass) 吗?
错误在,->where('tbclass.Class', $xclass)。你可能会做 ->where('tbclass.Class', $xclass->Class)
关注