php - 未定义的属性:Illuminate\Pagination\LengthAwarePaginator::$name

标签 php laravel pagination

我正在尝试从我的表中获取数据并将其显示在我的 View 中并对这些数据进行分页。我收到了这个问题,但找不到任何解决方案。我在之前的项目中做了完全相同的事情,而且效果很好。

这是我的 Controller

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

这是我的观点
<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()}}

最佳答案

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

应该是 $row->name,$row->email等...不是$users->name ,并更改 {{$users->links()}}{!! $users->render() !!}

关于php - 未定义的属性:Illuminate\Pagination\LengthAwarePaginator::$name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38475845/

相关文章:

php - 为什么 Laravel 命令中的自定义构造函数会导致 "Invalid argument supplied for foreach"?

找不到 PHP 类错误仅发生在 CircleCI 上

php - 在 where 条件中使用括号 ()、星号 *.. 等特殊字符

php - 如何仅在 Laravel 中出现日期时才验证日期

javascript - Bootstrap 模式中的 Laravel ajax 搜索

java - Hibernate Hql 查找分页器的结果大小

android - 在 android 中滚动时使用改造从 API 获取下 10 个项目的分页

php - MySQL:每组两个

php - mysql偏移真实行为

Laravel,如何将对象转换到新的 Eloquent 模型?