Ali Yiğit Ali Yiğit - 4 months ago 106
PHP Question

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$name

I am trying to get data from my table and show it in my view and paginate this data. I received this problem and couldn2t find any solution. I did the exactly same thing in my previous project and it worked well.

here is my Controller

public function hadiBirlikteCalisalimShow (){
$users =DB::table('birlikte_calisalim')->paginate(15);
return view('admin.birliktecalisalim',compact(['users']));
}


and this is my view

<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>İsim</th>
<th>Email</th>
<th>Tarih</th>
<th>İstek</th>
</tr>
</thead>

<tbody>
@foreach($users as $row)
<tr>
<td>{{$users->name}}</td>
<td>{{$users->email}}</td>
<td>{{$users->tarih}}</td>
<td>{{$users->message}}</td>
</tr>
@endforeach
</tbody>
</table>
{{$users->links()}}

Answer
@foreach($users as $row)
    <tr>
       <td>{{$users->name}}</td>
       <td>{{$users->email}}</td>
       <td>{{$users->tarih}}</td>
       <td>{{$users->message}}</td>
     </tr>
@endforeach

should be $row->name,$row->email.ect..not $users->name, and change {{$users->links()}} to {!! $users->render() !!}

Comments