Laravel: «Объект класса stdClass не может быть преобразован в строку» при передаче переменной в закрытие - PullRequest
0 голосов
/ 14 июля 2020

Я получаю такую ​​ошибку ErrorException

Это мой индекс ссылки

<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() }}

если я нажимаю ссылку на странице индекса, я получаю эту ошибку

Кто-нибудь может помочь ???

1 Ответ

0 голосов
/ 14 июля 2020

Не могли бы вы dd ($ xclass)?

Ошибка в, -> where ('tbclass.Class', $ xclass). Вы, вероятно, делаете -> where ('tbclass.Class', $ xclass-> Class)

Regard

...