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

Categories

I try to use laravel pagination in my custom CMS

the illuminate/pagination work, but not properly

this code for my controller work

       $cats= Category::paginate(2);

but when i want to calling the pagination link in this code in blade engine

{{$cats->links()}}

or 

{!! $cats->links() !!}

or 

{{$cats->render()}}

I get this error

call_user_func() expects parameter 1 to be a valid callback, no array or string given (View: C:xampphtdocsgitrepomvcframwork
esourcesviewadminproductscategory.blade.php)

enter image description here

git project url https://github.com/mohammadZx/mvcframwork/tree/log

you can check project in github on log branch

I think this problem belongs to laravel pagination service provider but still i don't know how register laravel providers or fix this problem


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

you have to register PaginationSerivceProvider. follow PaginationSerivceProvider in regsiter method and do required actions

Or

go to LengthAwarePaginator.php file and refactor a blade or view handler for this method with contained property you should know below method have all pagination system and just need to require in view handler

public function render($view = null, $data = [])
    {
        return static::viewFactory()->make($view ?: static::$defaultView, 
          array_merge($data, [
            'paginator' => $this,
            'elements' => $this->elements(),
         ]));
    }


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...