首页 > 解决方案 > Laravel:在刀片内调用 paginate()?

问题描述

我可以访问$files我的刀片内部调用的集合。我正在分页并将其设置为$allFiles.

<?php $allFiles = $files->paginate(12); ?>

在下面的刀片中,当我调用时:

<div>
   {{ $allFiles->links() }}
</div>

,我收到错误消息call to a member function links() on array。我不确定我做错了什么。


编辑:添加更多信息并显示是什么$allFiles。我将其记录在我的代码中并在下面添加:

Object
(
    [collection:protected] => App\Models\Collection Object
        (
            [connection:protected] => data
            [table:protected] => collections
            [timestamps] => 1
            [fillable:protected] => Array
                (
                    [0] => title
                    [1] => content
                )

            [casts:protected] => Array
                (
                    [smart_collection] => boolean
                    [is_app_collection] => boolean
                )

            [primaryKey:protected] => id
            [keyType:protected] => int
            [incrementing] => 1
            [with:protected] => Array
                (
                )

            [perPage:protected] => 15
            [exists] => 1
            [wasRecentlyCreated] => 
            [attributes:protected] => Array
                (
                    [id] => 2
                    [title] => Test
                )

            [original:protected] => Array
                (
                    [id] => 2
                    [title] => Test           
                )

            [dates:protected] => Array
                (
                )

            [dateFormat:protected] => 
            [appends:protected] => Array
                (
                )

            [events:protected] => Array
                (
                )

            [observables:protected] => Array
                (
                )

            [relations:protected] => Array
                (
                )

            [touches:protected] => Array
                (
                )

            [hidden:protected] => Array
                (
                )

            [visible:protected] => Array
                (
                )

            [guarded:protected] => Array
                (
                    [0] => *
                )

        )

    [resultsCount:protected] => 19
    [resultsProducts:protected] => 
    [cache:protected] => Array
        (
        )

    [splitOption:protected] => 
    [context:protected] => 
)

标签: phplaravellaravel-5

解决方案


推荐阅读