Laravel 类stdClass的对象无法转换为字符串(视图:C:\wamp64\www\Application 1\resources\views\admin\souentenance\themeValide.blade.php)

Laravel 类stdClass的对象无法转换为字符串(视图:C:\wamp64\www\Application 1\resources\views\admin\souentenance\themeValide.blade.php),laravel,laravel-5,eloquent,Laravel,Laravel 5,Eloquent,在过去的几天里,我一直在屏蔽我的部分代码。实际上,我想从数据库中检索信息,以便在表中显示它们 web.php Route::get('admin/soutenance/themeValide', 'SoutenanceController@index')->name('admin.soutenance.themeValide'); soutenanceController.php public function index() { $them

在过去的几天里,我一直在屏蔽我的部分代码。实际上,我想从数据库中检索信息,以便在表中显示它们

web.php

     Route::get('admin/soutenance/themeValide', 'SoutenanceController@index')->name('admin.soutenance.themeValide');
soutenanceController.php

     public function index()
    {
         $themes = DB::table('themes')
                  
                  ->join('soutenances', 'themes.id', '<>', 'soutenances.theme_id')
                  ->join('profs', 'profs.id', '=', 'themes.prof_id')
                  ->join('users', 'users.id', '=', 'themes.user_id')
                  ->select('themes.id', 'themes.title', 'profs.name AS prof_name', 'users.name AS user_name')
                  ->where('themes.validated', '=', true)
                  ->get();
        // dd($themes);
        
         return view('admin.soutenance.themeValide', compact('themes'));
    }
公共功能索引()
{
$themes=DB::表('themes')
->join('soutenances'、'themes.id'、'soutenances.theme\u id')
->join('profs','profs.id','=','themes.prof_id'))
->join('users','users.id','=','themes.user_id'))
->选择('themes.id','themes.title','profs.name作为教授名','users.name作为用户名')
->其中('themes.validated','=',true)
->get();
//dd(主题);
返回视图('admin.soutenance.themeValide',压缩('themes');
}
themeValide.blade.php

<div class="box-body">
          <div class="table-responsive">
            <table class="table no-margin">
              <thead>
                  <tr>
                    <th> ID </th>
                    <th> titre </th>
                    <th> Encadreur </th>
                    <th> Etudiant </th>
                    <th> Action </th>
                  </tr>
              </thead>
                <tbody>
                 
                  @forelse($themes as $theme)
                     
                      <tr>
                        <td>{{$theme->id}} </td>
                        <td>{{$theme->title}}</td>
                        <td>{{$theme->prof_name}}</td>
                        <td>{{$theme->user_name}}</td>
                        <td><span class="tools"><a href="{{route('admin.soutenance.create', $theme)}}"><i class="fa fa-edit"></i></a>
                            {{' | '}}
                        <i class="fa fa-trash-o"></i></span></td>
                            
                      </tr>
                  @empty
                         <tr>
                      <td></td>
                            <td> pas de Theme validé </td>
                        </tr>
                    
                  @endforelse

                </tbody>
              </table>
              </div>
          </div>

身份证件
乳头
安卡德雷尔
学生
行动
@forelse($themes作为$theme)
{{$theme->id}
{{$theme->title}
{{$theme->prof_name}
{{$theme->user_name}
{{' | '}}
@空的
主题有效期
@endforelse
当我在soutenanceController中执行此操作时

dd(主题)

我得到了期望的结果,但当我希望它显示在我的页面themeValide.blade.php中时, 它告诉我这个错误

类stdClass的对象无法转换为字符串(视图:C:\wamp64\www\Application 1\resources\views\admin\souentenance\themeValide.blade.php)


请告诉我。

您正在将
$theme
传递给
路由
帮助程序,该帮助程序将尝试将其用作字符串,并且它是一个对象。您需要传递所需的属性,很可能是
id

route('admin.soutenance.create', $theme->id);
添加你的
dd($themes)到问题以查看内部内容