Browse AI Field GuideForum Podcast
All ThreadsLeaderboard
  1. Discussions

    1. Popular This Week
    2. Popular All Time
    3. Solved
    4. Unsolved
    5. No Replies Yet

adiss's avatar

Convert array to Eloquent model

I try to implement search function with this package https://github.com/TomLingham/Laravel-Searchy. When Searchy query is done it return Array data. I dont need array i need Eloquent model becouse with array i cant implement pagination. I try to cast it to Notebook collection but i dont know how to do it. This is what i did and i got this error Call to undefined method Illumin

adiss's avatar
adiss's avatar sid40510yrs agoEloquent
3
5
Last reply by sid405 10yrs ago
bobbybouwmann's avatar

Bug with parameter ?page=0

Hee Jeffrey, I found a small bug in the pagination of a thread. When I visit any url with the parameter ?page=0 in the url the question is not shown. Only the replies. Let's take for example this url https://laracasts.com/discuss/channels/general-discussion/authentication-time-out?page=0#reply-97163 I only find these urls, on my profile page in my activity feed. Let me know if

bobbybouwmann's avatar
bobbybouwmann's avatar bobbybouwm...10yrs agoFeedback
0
1
pavlen's avatar

Laravel link route to wrong view

Hi, get very wierd situation,all works fine,and last time I try one link from my menu,see that routes link to wrong view. Here is route: Route::get('main', 'TestController@index'); In controller is this for return: public function index(){ $pagination = Test::latest()->paginate(10); return view('orders.index',compact(

pavlen's avatar
pavlen's avatar pavlen10yrs agoLaravel
4
1
Last reply by pavlen 10yrs ago
Pexilius's avatar

Paginate user articles

I have a route that displays all the groups of a specific person. But I would like to paginate this. Currently it's paginating all the groups per user. But I can't seem to simply just get the group. The relationship is many to many (with pivot ect) What I have at the moment is wrong, but how would I fix this? public function index() { $user = Auth::user(); $

Pexilius's avatar
Pexilius's avatar Francismor...10yrs agoLaravel
3
1
Last reply by Francismori7 10yrs ago
Wo33er's avatar

Multi-model Many Relationships

On Laravel 5.1; I've got a group with many users that have many reviews. I want to query all reviews of all users for a given group, paginate and list. So far I've got a users() belongsToMany relationship on the Group model, and a reviews() hasMany relationship on the User model. I feel that there must be a clean means to query and sort such a list leveraging these relationship

Wo33er's avatar
Wo33er's avatar Wo33er10yrs agoEloquent
4
1
Last reply by Wo33er 10yrs ago
miguelcamargo9's avatar

DataTables

I work with data tables, is a plug -in for the jQuery Javascript library search for pagination and the reports, so far had not presented me problem , because since the driver passed a parameter json format to view and longer , but came a query of eleventhousand records , when so many my method was everything a failure , now I want to load data from an ajax , to display a page l

miguelcamargo9's avatar
miguelcamargo9's avatar miguelcama...10yrs agoLaravel
4
1
Last reply by miguelcamargo9 10yrs ago
mstnorris's avatar

Larval and jScroll

When scrolling to the bottom of the page an error is thrown. "Failed to load resource: the server responded with a status of 404 (Not Found). mydomain.com/undefined" I am using jScroll, the pagination links are hidden but the content from the next page isn't loaded. ArticlesController controller public function index() { $articles = Article::latest('published_at')

mstnorris's avatar
mstnorris's avatar Jagdish-J-...1yr agoGeneral
26
1
Last reply by Jagdish-J-P 1yr ago
consigliere's avatar

Algolia Real Time Search

Please provide snippets (table with pagination) on how to use Algolia Real Time Search using just Jquery or Jquery Datatable.

consigliere's avatar
consigliere's avatar mstnorris10yrs agoTips
3
1
Last reply by mstnorris 10yrs ago
andremellow's avatar

Do you test everything?

When you are writhing your testes, how deep do you go? I'm about to start using behats e thinking abount how many scenarios I'll have. If you think in a CRUD feature will we have ( I know this is not a cookbook) C : Submit without fill any field (with client validation) and check every single field was validated Submit without fill any field (with server validation) and c

andremellow's avatar
andremellow's avatar andremello...10yrs agoTesting
7
1
Last reply by andremellow 10yrs ago
CedricBongaerts's avatar

Combining Paginate with OrderBy

I'm trying to make a posts view to by paginated (which I have been able to do) using this code: index.blade.php @extends('masterpage.app') @section('content') @foreach (array_chunk($posts->all(), 2) as $row) <div class="row"> @foreach ($row as $post) <article class="col-md-6">

CedricBongaerts's avatar
CedricBongaerts's avatar COTIGA7yrs agoLaravel
4
1
Last reply by COTIGA 7yrs ago
Demers94's avatar

Passing parameters to eager loading condition

Hello everyone, sorry for the not-so-explicit title, I couldn't find a better way to phrase it. I'm using a standalone version of Eloquent with a little Slim PHP forum I'm building. I have a Board object with has a hasMany relationship with the topics that have been posted in that board. I'm using a pagination system and passing the current page number to the URL, to calculate

Demers94's avatar
Demers94's avatar bobbybouwm...10yrs agoEloquent
3
1
Last reply by bobbybouwmann 10yrs ago
mercuryseries's avatar

Create a Laramap.com Clone app

Hi guys, I made this simple app "Laracarte" with Laravel 5.1 (kind of laramap.com clone) for learning purposes. Demo App: http://laracarte.herokuapp.com/ Source Code on GitHub: https://github.com/mercuryseries/laracarte Features: Authentication System (with ability to edit your profile informations) Geolocation by address Google Maps Integration Markdown Parser Simp

mercuryseries's avatar
mercuryseries's avatar as-many10yrs agoGeneral
5
1
Last reply by as-many 10yrs ago
rleger's avatar

Add custom section to a resource

Hi, I'm using Fractal for my api. I'm trying to include a custom section on my response that would be appended to my collection and give me some stats about the response. An example : If I'm getting messages, I currently get a response with messages and pagination, great... But I can't figure out is how to append a customized section that would give stats about my messages (rea

rleger's avatar
rleger's avatar rleger10yrs agoGeneral
0
1
vitorf7's avatar

Paginating grouped results by title

Hi everyone, I am slightly new with Laravel. I have been a member of Laracasts for a while and I have learned a lot here however the companies I worked for never wanted to do anything in Laravel. Thank God I finally started a new job where I can work with Laravel. I am however being faced with a really tricky situation. The Project is using Laravel 4. The project is basically d

vitorf7's avatar
vitorf7's avatar vitorf710yrs agoLaravel
9
1
Last reply by vitorf7 10yrs ago
pavlen's avatar

Laravel 5 paggination problem

Hi all, I have problem with my pagination : Controller code: $pagination = Orders::latest()->paginate(2); return view('orders.index',compact('pagination')); View code: {!! str_replace('/?', '?', $pagination->render()) !!} All data have been loaded on page,that is fine,also pagination is on bottom, but when click on page 2, get error: MethodNotAllowedHttpException in co

pavlen's avatar
pavlen's avatar kelvinferr...7yrs agoGeneral
8
1
Last reply by kelvinferreira 7yrs ago
jake2025's avatar

Laravel's belongsTo relationship

Greetings Pros, I know this is easy for you guys but i'm really confused about this. I have implemented a pagination ( which you can found in one of sir jeffrey's video activity feed is the video's name i think ) and etc... Here's the relationship: class Activity extends Eloquent { // public function user() { return $this->belongsTo('App\User'); }

jake2025's avatar
jake2025's avatar jake202510yrs agoEloquent
7
1
Last reply by jake2025 10yrs ago
jake2025's avatar

Laravel 5 : Filtering built-in paginator

Greetings pros, i have watched pagination tutorial by sir jeffrey but i was wondering how can i send the append request on the query and filter the result. Thank you in advance!

jake2025's avatar
jake2025's avatar brunofranc...8yrs agoLaravel
6
1
Last reply by brunofrancisco 8yrs ago
pavlen's avatar

Using mysql DATE function inside query

Hi. I have this query : $pagination =Orders::where('created_at' ,'=' ,'2015-07-24 07:22:00')->paginate(11); and it work fine, now I need a specific option,to check only date from timestamp. Sql query will be : SELECT * FROM orders WHERE date( created_at ) = '2015-07-24' NOw, how to implement date( created_at ) in Laravel query ? Tnx

pavlen's avatar
pavlen's avatar pavlen10yrs agoEloquent
6
1
Last reply by pavlen 10yrs ago
nickstarkloff's avatar

Link to the latest post

I 'm building a forum and I have a list of all the sections. And in these sections are threads. In this list of the sections I want to link to the latest post in a thread. As on this page, if you click on "Updated X minutes ago". So the link should look like this.. www.example.com/section/thread?page=1#post-123 Right now I can already link to the thread where the lat

nickstarkloff's avatar
nickstarkloff's avatar pmall10yrs agoLaravel
3
1
Last reply by pmall 10yrs ago
raygun's avatar

Should I have a model for each nav link topic? is that how it's done

Should I have a model for each nav link topic? is that how it's done? For instance, I have a blog with News and Video links in the nav bar. I know I can set it up how I want, but I'm new and was wondering is there any conventions to how a site should be set up. Should my News and Videos go in the same table or do they each get there own controllers and models. also if they wer

raygun's avatar
raygun's avatar deltasolut...10yrs agoTips
4
1
Last reply by deltasolutions 10yrs ago
christiangerdes's avatar

Advanced multiple paginations

Hi, I want to know how to treat every 5th row different in pagination. I have a $ads variable that keeps all ads with a active value of 1 in a pagination. Then I have another variable $business that keeps all ads with a active value of 2 in a pagination. My problem is that I don't know how to specify that I want 4 normal ads listed and then 4 business ads and then 4 normal ads

christiangerdes's avatar
christiangerdes's avatar painis10yrs agoLaravel
2
1
Last reply by painis 10yrs ago
BENderIsGr8te's avatar

ElasticSearch Query Builder

Hey All, I have been working in PHP for about 5 years, but never seriously until the past year. I'm self trained, but feel pretty confident about my abilities. I've never published anything publicly (except my Laravel Timezone Javascript/PHP companion which I use to store data in UTC but display it in the users current time zone based on their location). Anyway, I have been int

BENderIsGr8te's avatar
BENderIsGr8te's avatar mhh14229yrs agoGeneral
4
1
Last reply by mhh1422 9yrs ago
Kryptonit3's avatar

How to filter results based on URL query string

I have a model User and it hasMany Types. I have a page where I paginate all users. I also have a box off to the side with checkboxes with all the types in them. How would I filter the paginated content? I am assuming it has something to do with a query scope but I do not know how to apply it properly, and also without messing up the pagination. Something like mysite.com/users?

Kryptonit3's avatar
Kryptonit3's avatar jekinney10yrs agoEloquent
4
1
Last reply by jekinney 10yrs ago
mercuryseries's avatar

Pinterest (Clone)

Hi guys, I made a simple app "Pin Board" with Laravel 5.1 (kind of pinterest clone). Github link: https://github.com/mercuryseries/pinboard Demo App: http://quiet-badlands-9458.herokuapp.com/ Features: Authentication System (with ability to edit your profile informations) CRUD actions for a pin Mark a pin as 'favorite' Remove a pin from my favorite pins Simple pagina

mercuryseries's avatar
mercuryseries's avatar as-many10yrs agoGeneral
10
1
Last reply by as-many 10yrs ago
sharrpenized's avatar

Route model binding VS repository. Can they live together?

I have a controller. It has some methods with quite complex queries (like pagination) and also some very simple methods with trivilar queries (like destroy). It feels correct to put pagination logic in repository, however, I'm not sure what to do with the rest of controller methods which are trivial. I could use Route Model Bindings: public function destroy( Item $item ) {

sharrpenized's avatar
sharrpenized's avatar pmall11yrs agoLaravel
3
1
Last reply by pmall 11yrs ago
cshelswell's avatar

Is this full text search possible in eloquent?

I'm trying to build a query to do a full text search on products. I've been using Eloquent to build up the query based on a number of other factors such as pagination, order etc. I'm not using full text every time so how I'd got it is roughly like this (if i was doing a full text): public function getProducts($input['string']) { $query = $this->model->query(); if

cshelswell's avatar
cshelswell's avatar cshelswell11yrs agoEloquent
2
1
Last reply by cshelswell 11yrs ago
mikevrind's avatar

Memory usage

I recently built a webshop with L5 and last weekend the (Apache) webserver ran out of memory because of a spike in the number of visitors (from 9 to 200 visitors in just half an hour). The hosting company suggested to increase the RAM on the server with 2G (why wouldn't they advice to spend more money? :) ) But I'm just curious about your opinions about the memory usage. Is it

mikevrind's avatar
mikevrind's avatar veekthoven11yrs agoTips
9
1
Last reply by veekthoven 11yrs ago
andris-briedis's avatar

How to expand the template at various levels?

Hello. I have a basic template: the "master". It will include many files with tables extends to (). Not one time. Clicking on the "url". In all of these table files pagination is the same. Just different to the transferred numbers. Therefore pagination I want a separate file. Just can not figure out how it can be done with extends, sections and yield. Is it

andris-briedis's avatar
andris-briedis's avatar bobbybouwm...11yrs agoLaravel
3
1
Last reply by bobbybouwmann 11yrs ago
laraDev98's avatar

Laravel Package chumper/datatables fetches the entire table every time it is called.How can I add skip() and take() to it?

I'm using Chumper/Datatable https://github.com/Chumper/Datatable This is the code that I'm using to get json response for displaying the table. $query = Article::select('title','id','created_at')->orderBy('id','desc')->get(); Datatable::collection($query) ->addColumn('id', function($model){ return $model->id; }) ->addColumn('title', function

laraDev98's avatar
laraDev98's avatar laraDev9811yrs agoGeneral
0
1
KifayatMsd's avatar

select statement inside another select

Greetings .... How to write the following query in laravel eloquent ORM. select c.*, (SELECT COUNT(t.id) FROM dental_support_tickets t WHERE t.category_id=c.id AND t.status=0) AS num_tickets, (SELECT COUNT(a.id) FROM dental_support_category_admin a WHERE a.category_id=c.id) AS num_admins FROM dental_support_categories c WHERE c.status=0 order by c.title ASC They above query if

KifayatMsd's avatar
KifayatMsd's avatar jemirissel...3yrs agoEloquent
6
1
Last reply by jemirisselvi 3yrs ago
jrdavidson's avatar

Paginated Posts Started

For some reason if I go to all my posts and click on a new page in the pagination of posts. It shows a new page in the URL but only shows the same posts meaning it doesn't show the next set of posts I've started/contributed to.

jrdavidson's avatar
jrdavidson's avatar isimmons11yrs agoFeedback
3
1
Last reply by isimmons 11yrs ago
tuytoosh's avatar

use orWhere() in Eloquent

Hi all , I want to use orWhere() without using Query Builder and I want to return a collection... in Query Builder we have : $users = DB::table('users') ->where('votes', '>', 100) ->orWhere('name', 'John') ->get(); I want to grasp $users as a collection to paginate them with laravel pagination for example

tuytoosh's avatar
tuytoosh's avatar JarekTkacz...11yrs agoEloquent
6
1
Last reply by JarekTkaczyk 11yrs ago
dede02830's avatar

[L5] - Paginate fail after update

Hello, i have a problem with my pagination after a composer update. Before i have in my controller: $points = \DB::table('Point') ->leftjoin('Network', 'Network.networkID', '=', 'Point.networkID') ->leftjoin('TPoint', 'TPoint.tpointID', '=', 'Point.tpointID') ->paginate($this::NBRPARPAGES, array('Point.pointID', 'Point.ac

dede02830's avatar
dede02830's avatar dede0283011yrs agoLaravel
4
1
Last reply by dede02830 11yrs ago
laracastmike's avatar

paginate on union

Hi, I'm real problems getting pagination to work with unions, I have the following code which works, but can't get pagination to work $hardware_items = \DB::table('hardware_items') ->select(\DB::raw("inventory_number, id, serial_number, name, 'hardware' AS 'type'")) ->where('inventory_number', 'LIKE', $search)

laracastmike's avatar
laracastmike's avatar laracastmi...11yrs agoGeneral
0
1
abixalmon@me.com's avatar

paginating group_by queries

I am sure most of you have faced this problem, where pagination returns wrong total, if you use group_by in your query. I have created a simple solution, which i wanted to share for review. $query = Movies::select('movies.*')->join('movie_casts', 'movies.id', '=', 'movie_casts.movie_id')->groupBy('movies.id'); $movies = $this->customPaginate($query, $query->get()-&g

abixalmon@me.com's avatar
abixalmon@me.com's avatar abixalmon@...11yrs agoEloquent
0
1
yQvVWBIp's avatar

Get URL

Hello, I have done pagination using laravel. Now I have a URL : http://laravel.dev/home?page=2 page number can be varied. I can have URL using javascript function : window.location.href How do I get that string ? How can I get : page=2, page=3 using JAVASCript ? Thanks!

yQvVWBIp's avatar
yQvVWBIp's avatar shankarwra...11yrs agoGeneral
3
1
Last reply by shankarwram 11yrs ago
crazymonster's avatar

L5: Paginate works not at all

Hello. My query: ModelStuff->paginate(12); All is good, I have been received Collection, but when I dump the data, I can see: LengthAwarePaginator {#226 ▼ #total: 1 #lastPage: 1 #items: Collection {#212 ▶} #perPage: 12 #currentPage: 1 #path: "http://some.dev/artists/" #query: [] #fragment: null #pageName: "page" } When I try to access: http://some.dev/ar

crazymonster's avatar
crazymonster's avatar jekinney11yrs agoGeneral
4
1
Last reply by jekinney 11yrs ago
orosznyet's avatar

Paginator class is missing (L5)

I just tried to use the following code (just for testing): $data = [ 'items' => ['1'], 'totalItems' => 100, 'perPage' => 20, 'pagination' => null, ]; $data['pagination'] = \Paginator::make( $data['items'], $data['totalItems'], $data['perPage'] ); And I got this very simple and usually easy-to-fix error: Class 'Paginator' not found What

orosznyet's avatar
orosznyet's avatar mkwsra10yrs agoGeneral
16
2
Last reply by mkwsra 10yrs ago
nolros's avatar

Best Practice for collection parse to JS?

@JarekTkaczyk @bashy @pmall @rodrigo.pedra or anyone else that has any advice / best practices Sorry to bug you guys, but if I don’t ask I’ll never learn. In the case of my code below where I’m retrieving a model with a number of relations. I then parse it to extract a sub set of data that I then return to a view. I use Angular JS as my JS framework and use it for DOM manipulat

nolros's avatar
nolros's avatar pmall11yrs agoGeneral
5
1
Last reply by pmall 11yrs ago
jmfs's avatar

How to use pagination.php to change next/prev arrows

There's a file /resources/lang/en/pagination.php that has next/prev entries for the pagination arrows in it - how do I get my pagination to use this file?

jmfs's avatar
jmfs's avatar johnpatel7yrs agoGeneral
4
1
Last reply by johnpatel 7yrs ago
RachidLaasri's avatar

How to achieve this, eloquent tricks

Hi everyone, So, i have posts tables and i want to group them by the date in this format : Tuesday April 14 Post Post Wednesday April 15 Post Post But with pagination, i tried grouping by date format(l) but it doesn't work with pagination. Any help would be much appreciated.

RachidLaasri's avatar
RachidLaasri's avatar JarekTkacz...11yrs agoEloquent
17
1
Last reply by JarekTkaczyk 11yrs ago
fetchforo4's avatar

How to do this?

Hi there, For a forum I'm making, I'm working on a search feature that currently searches through users, topics, and posts. I also use pagination within the topic view to get rid of the clutter, and that's what this problem has to do with. So anyway... Say Bob posts on a topic and there are 5 posts (5 per page). I already have it so Bob gets redirected when he replies, assuming

fetchforo4's avatar
fetchforo4's avatar bashy11yrs agoGeneral
10
1
Last reply by bashy 11yrs ago
mstnorris's avatar

Responsive Twitter Bootstrap grid, array_chunk()

As a simple example to demonstrate my question, let's say that I want to show all the users from my app in a grid. Following the Crazy Simple Pagination video everything works well. Every six users, I create a new row. That is all well and good while I am using col-sm-2 since 2 goes into 12 six times. What if I want to make the page responsive, so that I have something like: &l

mstnorris's avatar
mstnorris's avatar foxted11yrs agoGeneral
6
1
Last reply by foxted 11yrs ago
bencarter78@hotmail.com's avatar

Clicking on paginated link redirects to truncated url with XAMPP (I know, it sounds crazy to me too)

Hi all I'm slowly losing the will trying to get a L5 application to run on my XAMPP server. Just to give you an overview of my setup... We have Windows Server 2008 which is running XAMPP v3.2.1. This is only accessible via our internal network. I've just ported an app from L4 to L5 and am now getting ready to deploy. Although I don't like the 'public' suffix to my url I have be

bencarter78@hotmail.com's avatar
bencarter78@hotmail.com's avatar bashy11yrs agoGeneral
11
1
Last reply by bashy 11yrs ago
henninghorn's avatar

Best way to "rewrite" paginate response?

I've been trying to implement the "Laravel 5 Repositories" package: https://github.com/andersao/l5-repository So far, so good. If I just return $this->repository->paginate() I get the data in an array named "data" and the pagination stuff in some other fields. I don't like the way it's formatted and I don't need the fields "next_page_url" and

henninghorn's avatar
henninghorn's avatar henninghor...11yrs agoGeneral
6
1
Last reply by henninghorn 11yrs ago
mstnorris's avatar

How do I paginate a **Posts** **Replies**

I have implemented pagination on my forum index page which lists groups of 12 posts along with details about each one including number of replies etc. I want to be able to paginate the replies when I view a certain post. What is the Eloquent (or query) that will allow me to achieve this? So far I have this but it throws an error. public function show($id) { $post =

mstnorris's avatar
mstnorris's avatar mstnorris11yrs agoGeneral
17
1
Last reply by mstnorris 11yrs ago
rgiaviti's avatar

jQuery Datatables and Laravel Server-side implementation

Hi guys! I am working on a datatable with more than 16.000 records. If I use Laravel's pagination, it works absolutely fine and with excelent performance. However, I need use the column sorting and "all collumn filtering". Datatables provide these features out of the box. If I use memory pagination of datatable, the performance is terrible, so I will need to use serve

rgiaviti's avatar
rgiaviti's avatar phpMick10yrs agoGeneral
17
28
Last reply by phpMick 10yrs ago
vipin93's avatar

How to show few content about image

Hey I try to make where user can upload images and I want show that images in pagination and every image have content(may be long) but I want show some content and link it to a page only about this image where it have comment long content and many more like in laracasts website ? thanks

vipin93's avatar
vipin93's avatar Ruffles11yrs agoRequests
8
1
Last reply by Ruffles 11yrs ago
Hao Zhou's avatar

Undefined function appends() in custom Laravel 5 paginator

Hi guys, I am using paginator to show data in a tabular format. There is a small requirement when it comes to where to place those links of pages: I want to float them right. Considering that Laravel is using Bootstrap 3 to render the layout, I know I can simply add class "pull-right" into the element. So I constructed a custom pagination presenter like so: namesp

Hao Zhou's avatar
Hao Zhou's avatar Hao Zhou11yrs agoGeneral
10
1
Last reply by Hao Zhou 11yrs ago
JackD's avatar

scroll down and load more

any idea what i need to have to make this pagination work like when i scroll down the list of data will load? instead of having pagination numbers

JackD's avatar
JackD's avatar dinis11yrs agoGeneral
6
1
Last reply by dinis 11yrs ago

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.