Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

php - 当我尝试使用links()时调用未定义的方法错误(Call to undefined method error when I try to use links())

When I try to use $student->links() I see this error :

(当我尝试使用$ student-> links()时,我看到此错误:)

Facade\Ignition\Exceptions\ViewException Call to undefined method App\Student::links()

(Facade \ Ignition \ Exceptions \ ViewException调用未定义的方法App \ Student :: links())

I checked the controller, model etc but all of them seem OK... How can I fix this?

(我检查了控制器,模型等,但它们似乎都还不错。如何解决此问题?)

(I tried this code both on my Macbook and VPS -CentOS7- but same problem occurs)

((我在Macbook和VPS -CentOS7-上都尝试了此代码,但出现相同的问题))

That part of my view looks like this:

(我观点的这一部分看起来像这样:)

      </tr>
            @endforeach
           </tbody>
         </table>
            {{ $student->links() }}
         </div>
       @endsection
  ask by Mustafa Hepekiz translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to paginate in your backend code.

(您需要在后端代码中进行分页。) $students = App\Student::paginate(15);

And then you can access the links()

(然后您可以访问links())

<div class="container">
    @foreach ($students as $student)
        {{ $student->name }}
    @endforeach
</div>

{{ $students->links() }}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...