dongqiao9394 2018-08-15 10:43
浏览 104
已采纳

面临的问题:方法Illuminate \ Database \ Query \ Builder :: links不存在

Hey everyone I was creating a laravel project and I wanted to add the pagination but I faced this error :

Method Illuminate\Database\Query\Builder::links does not exist. (View: C:\xampp\htdocs\TestingTaskesources\views\income\index.blade.php)

Here is the controller code:

public function index()
    {

        $income =Income::orderBy('created_at','desc')->paginate(1);
        return view('income.index', compact('income'));

    }

The view code:

@extends('layouts.app')
@section('content')
<h3>Profit</h3>
<br>
@if(count($income)>0)
@foreach($income as $income)
    <div class="card bg-muted">
    <h3><a href="/income/{{$income->id}}">{{$income->title}}</a></h3>
    </div>
@endforeach
    {{$income->links()}}
@else
<p>No result</p>

@endif
@stop
  • 写回答

2条回答 默认 最新

  • doufu8127 2018-08-15 10:58
    关注

    You have a typo in your code. change $income to $inc.

    @extends('layouts.app')
    @section('content')
    <h3>Profit</h3>
    <br>
    @if(count($income)>0)
    @foreach($income as $inc)
        <div class="card bg-muted">
        <h3><a href="/income/{{$inc->id}}">{{$inc->title}}</a></h3>
        </div>
    @endforeach
        {{$income->links()}}
    @else
    <p>No result</p>
    
    @endif
    @stop
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类