Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()}}
like image 349
Gvep Avatar asked Jul 20 '16 08:07

Gvep


1 Answers

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

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

like image 124
Raymond Cheng Avatar answered Jan 04 '23 16:01

Raymond Cheng