Category : laravel-pagination

I am trying to perform an infinity scroll pagination using window.scroll() method on laravel. Whenever I reach bottom of the page- loadMoreData(page) is called. beforeSend:function() successfully executes. .fail() calls from $.ajax() and alerts "server not responding". Here are my laravel and ajax codes below from 3 different files – index.blade, data.blade(Views/data), PostController.php INDEX.BLADE @extends(‘layouts.app’) @section(‘content’) ..

Read more

I want to shuffle and paginate data in laravel. when I use this code : `$questions = Question::where("exam_id",$exam->id)->shuffle()->paginate(1);` gives me this error : BadMethodCallException Call to undefined method IlluminateDatabaseEloquentBuilder::shuffle() and when I use this code: $questions = Question::where("exam_id",$exam->id)->paginate(1)->shuffle(); in dd($questions = Question::where("exam_id",$exam->id)->paginate(1)->shuffle());gives me a collection that has the first item and other items don’t exist. ..

Read more

I’m creating an API with laravel, this is my Article resource: public function toArray($request) { return [ ‘id’ => $this->id, ‘title’ => $this->title_persian, ‘image’ => $this->image, ]; } and this ArticleCollection resource: public function toArray($request) { return parent::toArray($request); } and this is my controller: public function taxonomyIndex(Article $article, Taxonomy $taxonomy){ $title = $taxonomy->name; $articles = ..

Read more

I recently found that in laravel SimplePaginate() $users->total() won’t work but when we use paginate() it works quite very well. When I tried to use $users->total() after SimplePaginate() I get an error given below: BadMethodCallException Method IlluminateDatabaseEloquentCollection::total does not exist. I wonder if I need a total count of pages via SimplePagination() like given below ..

Read more