Questions tagged [laravel-pagination]
Using pagination in Laravel Framework
236
questions
29
votes
3
answers
15k
views
Laravel Pagination is showing weird arrows
So I used simple Laravel pagination command of {{$posts->links()}} displaying 5 posts on one page.
Laravel's pagination is doing its job but it is displaying weird arrows. Refer the image below and ...
16
votes
4
answers
33k
views
Laravel How to display $hidden attribute on model on paginate
I'm using Laravel 5.5.
I read about this and know this function and it works makeVisible
$hidden = ['password', 'remember_token', 'email'];
I can display email using
$profile = auth()->user()-&...
15
votes
8
answers
24k
views
Laravel 5 - Manual pagination
Pagination::make() method doesn't exist in Pagination class anymore in Laravel 5.
Is there a workaround to make manual pagination work in Laravel 5?
9
votes
5
answers
15k
views
Laravel pagination not working with group by clause
It seems Laravel pagination does not working properly with group by clause. For example:
$users = Subject::select(DB::raw('subjects.*, count(user_subjects.id) as total_users'))
->join('...
8
votes
2
answers
9k
views
Syntax error or access violation: 1140 Mixing of GROUP columns laravel
I have written this query with pagination in it
$items = Item::select('items.*', 'sub_category_name', 'category_name', 'sub_category_slug', 'category_slug')
->join('sub_categories AS sc', '...
8
votes
2
answers
4k
views
Laravel 5 - Finding the pagination page for a model
I am working on building a basic forum (inspired by laracasts.com/discuss). When a user posts a reply to a thread:
I'd like to direct them to the end of the list of paginated replies with their ...
7
votes
5
answers
9k
views
How to use transform in paginated collection in laravel
I want to use map or transform in paginated collection in laravel 5.5 but I am struggling it work
This is what I was trying to do but getCollection is not available in LengthAwarePaginator as what we ...
7
votes
1
answer
31k
views
How to paginate with return as json laravel
I want to create a pagination with return as json, but I'm getting an error like below
ErrorException in Macroable.php line 74:
Method links does not exist.
here my controller code
public ...
6
votes
5
answers
24k
views
laravel show only next and previous link in pagination
I ma trying to use Laravel Pagination and I only want to show the Previous and Next link with out the number 1 2 3 ...
how could I do that? I followed Laravel page :
"Simple Pagination"
If you are ...
6
votes
2
answers
10k
views
get pagination data by a specific page number
I want to get Data by page number,
in normal when we use this code
$jobs = Jobs::paginate(10);
laravel get data by GET "page" parameter that defined in URL,
if our URL be http://www.example....
6
votes
5
answers
21k
views
Using limit parameter in paginate function
Is it possible to use 'limit' parameter in paginate() function?
I'm trying this:
$users->where(...)->limit(50)->paginate($page)
...and now, if I have 100 users in the database then the ...
5
votes
3
answers
7k
views
Laravel pagination showing duplicate and replacing random row
I am using laravel 5.4 with pagination and I have an issue where a row from my database shows up twice, once on two out of the 4 pages. When I delete the row however both are removed but the total ...
5
votes
2
answers
7k
views
Laravel 5 Pagination linking to wrong place
I'm currently updating one of my projects to Laravel 5 from 4.2. I'm aware a lot has changed with the paginator class but i really can't figure out why this isn't working. I call paginate() on ...
5
votes
1
answer
12k
views
Laravel pagination not working with array instead of collection
I'm trying to paginate an array data set and it has proven more challenging than I thought.
I'm using Laravel 5
So I have an abstract interface/repository that all my other models extend to and I ...
5
votes
2
answers
4k
views
laravel hydrateRaw/fromQuery and eager loading with pagination
I currently found out that you can hydrate an Raw sql query.
I have following query:
DB::table(DB::raw('(SELECT *, Y(location) AS longitude, X(location) AS latitude FROM meetings WHERE MBRCONTAINS(@...
5
votes
2
answers
697
views
laravel paginate when use select case and parameter binding
Laravel Version: 5.5
PHP Version:7
Hi, I want to execute this query:
select (case
when(title like 'my-keyword') then 1
when(description like 'my-keyword') then 2
) as ordering from products ...
4
votes
1
answer
14k
views
Laravel Pagination Error -- Call to undefined method stdClass::links()
I developed a laravel application and i want to paginate a view,
look my controller.
$times=DB::table('timesheets')
->leftJoin('users', 'timesheets.timesheet_user', '=', 'users.id')
->...
4
votes
2
answers
11k
views
Laravel pagination get variables
I have a page that list apartments depending on book dates like this
mypage.com/finder?date-from=2011-03-04&date-to=2011-03-12
Everything is right, I am getting the date-from and date-get from ...
4
votes
1
answer
27k
views
Call to a member function paginate() on array
I am working with Laravel5.0 . I want to add paginate() to the following function of my controller part.
public function index()
{
try{
$val=DB::connection()->getDatabaseName();
...
4
votes
3
answers
14k
views
Laravel sortBy paginate
I have a posts table and comments table, comment belongs to post, and I have the relationship setup in Post and Comment model. I did sort posts by the number of comments of each post like this:
...
4
votes
2
answers
1k
views
Laravel 5/ 5.4 paginator is not working in NGINX production environement
In my local environment i did $items = Model::paginate(10); and it worked. Then i pushed it to production and when i click on the pagination links it displays page 1 again and again. then i did dd($...
4
votes
1
answer
270
views
Random characters are added in pagination links in laravel 5.2
I have a little issue, Please take a look.
I have shown some data on a page based on some condition filtering, Everything works good except Pagination. I can't add the filter parameters to the ...
4
votes
4
answers
10k
views
Laravel fetch data from two tables without join with pagination
I want to fetch results from two tables properties and properties_x where properties.address or properties_x.address_x like test with laravel pagination.
There is no foreign key relationship between ...
4
votes
1
answer
28k
views
Laravel Pagination with eloquent Queries
I am trying to paginate my template which has a table on it.
This is my function in the controller which has the eloquent queries.
public function orderbydate()
{
$order =DB::table('...
4
votes
1
answer
1k
views
Using pretty URLs with Laravel 5.1 Pagination
I am writing a website using the Laravel 5.1 framework, and I'm trying to figure out how to use pretty URLs (pages/2 as opposed to pages?page=2). It actually surprised me that they haven't included a ...
4
votes
1
answer
1k
views
Pagination not showing after I use Resource to display data
I'm having issues with pagination after I use a resource to display data. Before this, I was using this code to display data, and the output shows the pagination as well.
Output
Controller
$All = ...
4
votes
2
answers
2k
views
How to Paginate loaded relation with Laravel API resources
I need to load model relations in it's resource and paginate them.
In my case i have Category and Path models, plus CategoryResource and PathResource
The toArray method of CategoryResource is like ...
3
votes
1
answer
97
views
Can't use paginate after using switch. - Laravel
I want to use the switch before using paginate. But am getting this error in my view -
Call to undefined method Illuminate\Database\Eloquent\Builder::links().
My Code -
MyController.php
$var = ...
3
votes
2
answers
4k
views
How to paginate in Laravel when using Modell::find(array())
I'm grabbing some data in Laravel using the find method and only grabbing the id's I want:
$my_ids = array(1,4,5,10);
$results = Model::find($my_ids);
However, if I try to paginate via Model::find($...
3
votes
1
answer
2k
views
Laravel Voyager server-side pagination links not showing
I am developing with Laravel 8.4 ("laravel/framework": "^8.40") and Voyager 1.4 ("tcg/voyager": "^1.4").
I am facing an unusual bug with Laravel Voyager. When I ...
3
votes
2
answers
3k
views
Laravel 5 how to use pagination with files list?
I have one problem with my script. I did foreach with files list but I need pagination, for example 15 files per site. What should I do now? Thanks for help :)
Controller:
$files = Storage::allFiles(...
3
votes
1
answer
9k
views
Laravel 5.0 Pagination render() method return HTML text
I have a controller which send some product to the view. In the controller I paginated the data using
...
// Controller code
Product::paginate(1) // because I only have 2 dummy data, 1 product per ...
3
votes
2
answers
2k
views
Laravel Pagination
How can I create a pagination in laravel?
My Model
Post
function comments() {
return $this->hasMany('Comment')
->orderBy('created_at', 'desc');
}
Comment
function posts(...
3
votes
2
answers
861
views
Laravel Collection paginate does not exist
I'm trying to implement basic pagination when retrieving notifications, but I get the following error.
Method
Illuminate\Notifications\DatabaseNotificationCollection::paginate does
not exist.
public ...
3
votes
4
answers
1k
views
Display laravel Pagination links twice in a page
I have implemented a laravel pagination in one of my project where pagination is working like a charm.
I have a requirement to display a pagination links on top of the table as well as the bottom of ...
3
votes
2
answers
5k
views
How to get pagination links using ajax (laravel 4.2)
Good day,
How can I pass e.g: $transactions->links(); when doing an ajax call on laravel?
Heres my Controller on a normal request:
$transactions = DB::table('x_general_transactions')
->...
3
votes
1
answer
2k
views
Laravel Livewire Multiple Pagination In One Page
I'm using Laravel Livewire and here I have 3 tables that showing on one page but the problem is the pagination showing correctly but not working(the URL change to http://127.0.0.1:8000/blogpost?...
3
votes
0
answers
340
views
links method does not exist using laravel pagination?
I am using pagination with Laravel 5.4 by this query.
$items = Item::with('likes')->whereStatus('1')->paginate(20);
And how i am rendering it in view
{{ $items->links() }}
this works fine ...
3
votes
2
answers
2k
views
Laravel Custom Pagination
Having problems getting my pagination to work in Laravel 5.2 I use a foreach to generate a list of objects where each object has a certain ranking. (competition)
The first query I used was this one:
...
2
votes
1
answer
2k
views
How to limit the number of page links in Laravel?
I have 500+ records in Users table and I am showing list using following code in my Blade template.
In Controller
$users= Users::paginate(5);
In Blade view
$users->links();
This is showing pages ...
2
votes
1
answer
3k
views
Remove row from pagination inside of transform
I have a variable that is a pagination object
$pagination
I am changing things inside of it using transform
$pagination->getCollection()->transform(function ($item, $key) use(&$data, &...
2
votes
2
answers
8k
views
Laravel 5.4 - get entrys where column contains specific string
I'm geting the following error if I try to get database entrys where the name contains a passed string.
Invalid argument supplied for foreach()
.
$search = $request['search'];
$key_search = ...
2
votes
2
answers
3k
views
How to get specific columns in Laravel Eloquent with pagination?
I use this table schema:
Schema::create('forms', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 255)->default('');
$table->text('html')->...
2
votes
2
answers
2k
views
Manual Pagination Error - Laravel 5.0
I am getting the following error while passing an array, count(array) and itemsPerPage as arguments.
Call to undefined method Illuminate\Pagination\Paginator::make()
I tried following with it but ...
2
votes
3
answers
4k
views
how to add custom(new) column in laravel pagination collection result
I am creating an API and I want to add extra column in the result of pagination query. For example I have price and discount in my database. I want to send discounted_price column with result set.
...
2
votes
2
answers
3k
views
laravel having: Column not found
my following code is like this:
$places = DivePlace::selectRaw("*,(st_distance_sphere( POINT(".$lon.",".$lat.") , point(lon, lat))/1000) as distance")
->havingRaw("distance < ".$radius)
...
2
votes
1
answer
121
views
Paginate doesn't work as expected uisng laravel and jq
I am working on a filtering data. As there is <input> and if someone start typing I am calling jq function to send a request to my controller. It is working fine. Even I am getting filtered data ...
2
votes
2
answers
5k
views
How to use laravel pagination with filter
I have getCanSeeAttribute function in post model, and I try to get posts with pagination using filter()
$posts = Post::where(function ($query1) use ($users) {
$query1->where('...