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

movepixels's avatar

Find Neighbors

Is there a method or functionality in Laravel to find the record before and after a record? Example: display a page / pagination Query database with whatever params and say return 25 records. Click on say the 6th record you go to view that page but you want to say to the user Next Profile / Previous Profile how would you then from the original query get record #5 for previous a

movepixels's avatar
movepixels's avatar Snapey7yrs agoLaravel
5
1
Last reply by Snapey 7yrs ago
LaraBABA's avatar

How to get a chronological id from a collection?

Hello, I am having a small problem but cannot find a good way to deal with it. Here is my code: $datas = User::whereNotIn( 'role_id', array(1, 2) ) ->whereNotIn ( 'total_points', array(0) ) ->orderBy('total_points', 'desc') ->paginate(20); I am pulling 2

LaraBABA's avatar
LaraBABA's avatar Snapey7yrs agoLaravel
2
4
Last reply by Snapey 7yrs ago
istanbouly's avatar

Laravel recursively eager load relations to paginate them

Hello Guys, there is a problem that I have been struggling with for too long time yes it is the eager loading but not just simple eager loading first I will provide the exact same scenario for my case then I will show you some of my attempts finally I will leave it to you to help me anyway thanks in advance. I have three Models Post , Comment , Reply each eager loads the other

istanbouly's avatar
istanbouly's avatar istanbouly7yrs agoLaravel
5
1
Last reply by istanbouly 7yrs ago
V1nk0's avatar

Caching complete lists or just the id-references

I'm currently trying to introduce cache into a project. To make the example simple I will use an example of a blog having categories and posts. A category can have multiple posts assigned, and a post can be assigned to multiple categories. I'm doubting between the following two strategies: Strategy A: Caching the single posts Caching the complete list of posts for specific lis

V1nk0's avatar
V1nk0's avatar dkroft4yrs agoLaravel
3
1
Last reply by dkroft 4yrs ago
GTHell's avatar

How to remove API throttling?

I have pagination route in the API.php and you know, the user keep clicking next next and then get throttling errors. How can I avoid that. It's local service so I don't care much about DDOS.

GTHell's avatar
GTHell's avatar s4muel7yrs agoLaravel
3
1
Last reply by s4muel 7yrs ago
Penaf's avatar

Undefined Builder::links() when paginating many to many relation

Good evening, while this bit on my controller works perfect: public function info($coleccao_tematica) { $coleccaoTematica = ColeccaoTematica::where('slug', 'LIKE', $coleccao_tematica) ->withCount('multimedia', 'especie') ->with('multimedia', 'poi', 'vid', 'capa') ->with(['especie' => function ($query) {

Penaf's avatar
Penaf's avatar staudenmei...7yrs agoEloquent
2
1
Last reply by staudenmeir 7yrs ago
Loach's avatar

Help me understand how paginated search works.

I have a form that I am using to search. I post to a new page that shows the search results, however when i click on the 2nd pagination link i get an error. Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message Here is the form. <form method="POST" action="/searchresults" class="form-horizontal"> {{ csrf_fie

Loach's avatar
Loach's avatar bluemagent...7yrs agoLaravel
2
1
Last reply by bluemagenta 7yrs ago
martinszeltins's avatar

PHP How to create urls properly?

I have never understood how to create proper URLs. Every time I end up with trying to figure out if I should do ?var=value or &var=value and then if ?var=value already exists then I end up with ?var=value&var=value. For example: I have pagination and my URL could look like this www.example.com OR www.example.com?name=John Then my pagination link is href="?page=2&q

martinszeltins's avatar
martinszeltins's avatar Yorki7yrs agoPHP
1
18
Last reply by Yorki 7yrs ago
petritr's avatar

How can i search inside each paginated page vue

How can i search inside each paginated page ? I use laravel pagination for pagination. "current_page": 1, "data": [], "first_page_url": "app./api/logs?page=1", "from": 1, "last_page": 4, "last_page_url": "appl/api/logs?page=4", "next_page_url": "appl/api/logs?page=2", &quo

petritr's avatar
petritr's avatar petritr7yrs agoVue
4
1
Last reply by petritr 7yrs ago
Smsma's avatar

react.js with laravel relationship

this error happend when I add {client.company.name} in view Uncaught TypeError: Cannot read property 'name' of null in CompanyController public function index(request $request) { $clients = $this->client->with('company')->orderBy('date_created','DESC'); if($request->search){ $clients = $clients->where(function($quer

Smsma's avatar
Smsma's avatar Smsma7yrs agoLaravel
2
1
Last reply by Smsma 7yrs ago
Smsma's avatar

react.js with laravel relationship

this error happend when I add {client.company.name} in view Uncaught TypeError: Cannot read property 'name' of null in CompanyController public function index(request $request) { $clients = $this->client->with('company')->orderBy('date_created','DESC'); if($request->search){ $clients = $clients->where(function($quer

Smsma's avatar
Smsma's avatar Smsma7yrs agoJavaScript
0
1
rashan88's avatar

FatalErrorException ERROR Call to a member function links() on string

i am trying to laravel pagination but when i am clicking on 2nd link above error is comming here my controller `` $searchResult = Property::where('purpose', $request['purpose']) ->whereHas('city', function ($qry) use ($cityName) { $qry->where('name', 'like', $cityName); }) ->whereHas('catagory', function ($qry) use ($catagory) { $qry->where('type', $catagory); })-&g

rashan88's avatar
rashan88's avatar tykus7yrs agoLaravel
1
1
Last reply by tykus 7yrs ago
petritr's avatar

Problem with search vue

I have problem with the search when i add pagination in vue: <input class="search ml-2" type="search" placeholder="Search" v-model="searching"> <log v-for="log in logs" :log="log" :key="log.id"> </log> <pagination :meta_data="meta_data" v

petritr's avatar
petritr's avatar Robstar7yrs agoLaravel
3
1
Last reply by Robstar 7yrs ago
chrisgrim's avatar

Creating Brand Categories

Hi, Right now on my index blade I am using @foreach ($brands as $brand) @if ($brand->channel_id == 1) @endif @endforeach --- @foreach ($brands as $brand) @if ($brand->channel_id == 2) @endif @endforeach My index method is public function index(Channel $channel) { if ($channel->exists) { $brands = $channel->brands()->latest()->get(

chrisgrim's avatar
chrisgrim's avatar chrisgrim7yrs agoLaravel
2
1
Last reply by chrisgrim 7yrs ago
brentxscholl's avatar

Paginating grouped By notifications

I am trying to display all notifications on a page and group them by day (to show a time timeline), but I am unable to properly paginate the notifications. Here is my code: View: @foreach ($notifications as $day => $notifications) <div class="row notification-day"> <div class="col col-sm-2&quo

brentxscholl's avatar
brentxscholl's avatar jlrdw7yrs agoLaravel
5
1
Last reply by jlrdw 7yrs ago
mufasaparadox's avatar

How to append query string to new url?

To explain this, I’m gonna try to use an example and maybe it’ll give you a better picture of it hopefully. I’m using pagination on my project and added $variable->appends(get)->links to keep query strings in the next page of pagination. Is there a way to use or mimic this when pressing a form button for submission, which would have action attribute with a url, to add a

mufasaparadox's avatar
mufasaparadox's avatar Cronix7yrs agoLaravel
6
1
Last reply by Cronix 7yrs ago
robaim's avatar

what is the problem on my php code!!

i need help , when i click a numbers of pagination , the same page state the code::

robaim's avatar
robaim's avatar Cronix7yrs agoCode Review
7
2
Last reply by Cronix 7yrs ago
mustafaabdujalil's avatar

Apis

using pagination in api request ex : send users ten per page thanks

mustafaabdujalil's avatar
mustafaabdujalil's avatar jlrdw7yrs agoLaravel
5
1
Last reply by jlrdw 7yrs ago
weavers54325's avatar

Paginate while returning array of Api resource objects to the resource collection

I need to send multiple objects to the api resource colection. So I am returning multiple Objects inside array. Everything works fine but not showing any pagination meta data. like Current_page,next_page url etc. My resource <?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\Resource; class ServiceProviderCollection extends Resource { p

weavers54325's avatar
weavers54325's avatar hasanablak1yr agoLaravel
25
443
Last reply by hasanablak 1yr ago
AtomCoder's avatar

Group Caching

Can't see any solid information on this, not even sure if it's available. I have an 'articles' page on my website with the content being changed or updated every 2 or 3 days. I'm currently passing the page number from pagination and caching like so articles_page_1, articles_page_2 etc...... This works fine! The problem is, when I update the content on the articles page I want t

AtomCoder's avatar
AtomCoder's avatar AtomCoder7yrs agoLaravel
4
1
Last reply by AtomCoder 7yrs ago
Sabbir345's avatar

Eliment UI Table index problem

i have a eliment ui table. when i am click eliment ui pagination . after one page index start with 1 . example : if first page 10 row. then legally second page row start index with 11 , 12 and so on but my index start with 1 , 2 Here is my Code <el-table :data="adminlog" stripe border style="width: 100%"> <el-table-column type="index" labe

Sabbir345's avatar
Sabbir345's avatar Sabbir3457yrs agoVue
0
1
Miko55's avatar

Datatables static row at bottom

I have leaderboards with usernames and their points. There is pagination every 10users. First three users have custom classes so they are colored gold/silver and bronze. Now what I want to do is to have a static row at bottom for example and in that row currently logged in user would be shown, his place, username and points. Places are made with index column. So how should I ap

Miko55's avatar
Miko55's avatar Miko557yrs agoLaravel
0
1
clat23's avatar

How to specify page number to retrieve on a Laravel Scout search

I've read the documentation on Laravel Scout Pagination: https://laravel.com/docs/5.6/scout#pagination However the documentation does not specify how to retrieve other pages. How would I go about doing this?

clat23's avatar
clat23's avatar clat237yrs agoLaravel
5
1
Last reply by clat23 7yrs ago
ralphdns's avatar

my SearchPostsController@store doesnt recognise my Post model

error message: Class 'Post' not found For this reason, my Search engine is worthless...pls help me improve see the SearchPostsController namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; /* use Illuminate\Http\Request; */ use Request; use Illuminate\Support\Facades\Input; use\DB; use\Post; class SearchPostsController extends Controller { /** * Dis

ralphdns's avatar
ralphdns's avatar Abi7yrs agoLaravel
1
1
Last reply by Abi 7yrs ago
petritr's avatar

Display data with vue js

How can i display data in an table with vue js ? I can loop the data and display it in the frondend but i need to change to vue table, with search and pagination. Any help ?

petritr's avatar
petritr's avatar petritr7yrs agoLaravel
4
1
Last reply by petritr 7yrs ago
petritr's avatar

Table witch real time search

Im very new to Vue js i want to show data in a vue table with an real time search. Any help with this? Looking or an easy with very fast searching. I need also pagination for the table.

petritr's avatar
petritr's avatar petritr7yrs agoVue
2
1
Last reply by petritr 7yrs ago
ralphdns's avatar

my search query is not displaying posts results 100%.

error1: Undefined property: stdClass::$user (View: C:\xampp\htdocs\infoblog\resources\views\page\search.blade.php) error2: Undefined property: stdClass::$photo (View: C:\xampp\htdocs\infoblog\resources\views\page\search.blade.php) see the SearchPostsController@store: namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; /* use Illuminate\Http\Request; */ use Re

ralphdns's avatar
ralphdns's avatar ralphdns7yrs agoLaravel
5
1
Last reply by ralphdns 7yrs ago
Smsma's avatar

BadMethodCallException Method Illuminate\Database\Eloquent\Collection::getCollection does not exist.

I want to return faqs with translation using pagination when I try this code that error appear what is the solution to do this ?? public function getFaqs() { if (config('app.locale') === 'en') { $data = Faq::with('translations') ->get(['id', 'question', 'answer']) ->getCollection()

Smsma's avatar
Smsma's avatar Yorki7yrs agoLaravel
6
1
Last reply by Yorki 7yrs ago
Kabir's avatar

DataTable became very slow!

I'm using dataTable in my project and it's working fine. But when the amount of data is thousand plus or more, it's becoming very slow to load the page. How can i fix this? May be pagination can be a solution. But i need to use dataTable's search filter. So how can i fix this problem using dataTable?

Kabir's avatar
Kabir's avatar jlrdw7yrs agoGuides
2
1
Last reply by jlrdw 7yrs ago
4xjbh's avatar

Select2 response fail

I am having trouble getting this to make a response and I am not sure why. The select2 control seems to respod correctly but the function seems to be the problem....I think. Any assistance would be appreciated. ROUTE Route::get('/api/selectcompany', 'CompanyController@selectcompany'); CONTROLLER public function selectcompany(Request $request) { $term = trim($reques

4xjbh's avatar
4xjbh's avatar 4xjbh7yrs agoRequests
4
1
Last reply by 4xjbh 7yrs ago
crnkovic's avatar

Bidirectional polymorphic many-to-many

Hey artisans, I've been scratching my head every time I try to do this. I have 2 types of user, say UserA and UserB. And 2 types of posts: PostA and PostB. I want to create a table, let's say items, that's going to morph both: $table->morphs('user'); $table->morphs('post'); I've been trying to implement this on both User side and Post side, both it doesn't seem like Eloq

crnkovic's avatar
crnkovic's avatar crnkovic7yrs agoEloquent
6
1
Last reply by crnkovic 7yrs ago
Valeri0's avatar

Separate routes to index and search

Hello friends, I used the method "index" in my controllers to get data with pagination, but paginated results are not suitable to populate a select box. In this case I need all plain results list eventually filtered with a query param like searchable select-box. Lately I see Laravel Nova presentation by Taylor and he made me think to use two different routes. Do you u

Valeri0's avatar
Valeri0's avatar jlrdw7yrs agoLaravel
1
1
Last reply by jlrdw 7yrs ago
ahmadbadpey's avatar

prepend to paginator fo dingo api in laravel

I'm using Dingo laravel api package. as you know this package has many features include pagination results. Suppose in a controller method I want to return paginated Post of my app. like this : public function category_posts ($cat_id) { $posts = Post::where('active',true) ->whereHas( 'categories', function ($que

ahmadbadpey's avatar
ahmadbadpey's avatar jlrdw7yrs agoLaravel
1
1
Last reply by jlrdw 7yrs ago
moses's avatar

How can I display dinamyc key of array in the laravel blade?

My controller like this : public function index(Request $request) { $param = $request->all(); $data = $this->itemDetailRepository->getData($param); return view('item-detail.index', compact('param')) ->withItems(count($data)>0?$data:null); } If I debug $data or in laravel (dd($data)), the result like this : So the array $data is collection an

moses's avatar
moses's avatar burlresear...7yrs agoLaravel
3
1
Last reply by burlresearch 7yrs ago
petruspetrus's avatar

Laravel architecture

Hi - Wonder if anybody can help with the following. I'm new to both Laravel and PHP so assuming I know nothing would probably not be a bad starting point :-) I have a remote database that contains a table holding enquiries from users of a client's website. I want to replicate these enquiries in a local table on my laravel database for processing in a back office system, so each

petruspetrus's avatar
petruspetrus's avatar petruspetr...7yrs agoLaravel
4
1
Last reply by petruspetrus 7yrs ago
AbdulBazith's avatar

Is it possible to redirect to index method() in controller by ajax request from view.blade laravel

Guys I am working with a project. I have a view.blade (Location_details.view) file which displays the records in tabular format. I also have a search box in my view.blade. When I type a name in that search box, the change event runs in ajax and it moves to controller to search the name typed in the search box and returns the value. My doubt is instead of returning the result, i

AbdulBazith's avatar
AbdulBazith's avatar AbdulBazit...7yrs agoLaravel
0
1
Nameless_0's avatar

Laravel + Vuejs autocomplete with one to many relationship

Hi everyone! I need some help in adding a autocomplete function in this app. I'd like the data from my other table (employees table) to be displayed when ever the user inputs inside the text box and displayed along the class cards when selected. I am having a hard time since i'm really new to using one to many relationships in laravel and vuejs. Thanks! I already fixed both tab

Nameless_0's avatar
Nameless_0's avatar Nameless_07yrs agoVue
3
1
Last reply by Nameless_0 7yrs ago
AbdulBazith's avatar

How to return more than one variable to ajax from controller

Guys iam working with a project. This is my controller $xcess_milks = Excess_milk::get(); return $xcess_milks; this my ajax <script type="text/javascript"> success:function(data) { var res=''; $.each (data, function (key, value) { res += '<tr>'+ '

AbdulBazith's avatar
AbdulBazith's avatar AbdulBazit...7yrs agoLaravel
12
1
Last reply by AbdulBazith 7yrs ago
invaderVim's avatar

Package for Laravel and DataTables

Hey everyone, I made a package to allow for easy DataTables pagination, searching and sorting for Laravel using Eloquent models and I was wondering if I could get some input. I know it's not perfect and any constructive criticisms or suggestions would be greatly appreciated. https://packagist.org/packages/the-reserve/laravel-data-table-paginator

invaderVim's avatar
invaderVim's avatar invaderVim7yrs agoCode Review
0
1
devamit2018's avatar

load large data in ubuntu

i have a project in laravel and deployed in ubuntu virtualbox.but it gives error when loading the controller having records 90k.after keeping limit it works fine..need suggestions to resolve it..i have kept manual laravel pagination

devamit2018's avatar
devamit2018's avatar devamit201...7yrs agoLaravel
5
2
Last reply by devamit2018 7yrs ago
nhayder's avatar

How to paginate hasMany relationship in user article query

i have hasMany relationship for user articles, This is my user model public function articles() // returining correct data { return $this->hasMany(Article::class); // this get all aricles related to a user } in user controller im passing the data to the view like this public function articles($id) { $subscriber = User::find($id)->with

nhayder's avatar
nhayder's avatar nhayder7yrs agoEloquent
8
1
Last reply by nhayder 7yrs ago
Kisiara's avatar

Cannot find or reference aliased modules using laravel mix's webpackConfig

I am using nwidart modules, laravel 5.6 and a Mac Pro Sierra. For some unfortunate reason I just cant seem to get aliased modules on laravel mix to work at all. I have a file ** /Modules/Core/Resources/assets/js** export const core = { prefix: 'core', paths: [ { url: 'redis', pagination: false }, { url: 'modules', pagination: false }, { url: '

Kisiara's avatar
Kisiara's avatar Kisiara7yrs agoMix
1
1
Last reply by Kisiara 7yrs ago
jagdishabhiandroid's avatar

How to add more elements to a resource data collection in REST API

i want to add more elements from different table to a resource data collection i have created first how can i do this with pagination here is my current code: public function seefav(Request $request) { $validator = \Validator::make($request->all(), [ 'student_id'=> 'required', ]); if ($validator->fails

jagdishabhiandroid's avatar
jagdishabhiandroid's avatar jagdishabh...7yrs agoLaravel
2
1
Last reply by jagdishabhiandroid 7yrs ago
jagdishabhiandroid's avatar

Edit API response

i want to change my Api response without losing pagination and meta feature here is my code which am using right now <?php public function seefav(Request $request) { //echo $request->student_id; $validator = \Validator::make($request->all(), [ 'student_id'=> 'required', ]); if ($validator->fails

jagdishabhiandroid's avatar
jagdishabhiandroid's avatar Cinek7yrs agoLaravel
1
1
Last reply by Cinek 7yrs ago
Bosstone's avatar

Infinite Scroll - JScroll

Hi Folks, I am trying to lazy load data from Mysql - To test, I have put 8000 entries into the database. I have added <div class = "infinite scroll" to my HTML Source: <div class="infinite-scroll"> @foreach($projects as $project) <p style=""><b>Kategorie: {{ $project->cat_name

Bosstone's avatar
Bosstone's avatar aurawindsu...7yrs agoJavaScript
1
1
Last reply by aurawindsurfing 7yrs ago
Nameless_0's avatar

Laravel 5 vuejs SQLSTATE[23000]: Integrity constraint violation

Hello everybody. I am trying to create a crud app but when I try to add I get the error POST http://itventors.test/api/employee 500 (Internal Server Error) and SQL state error Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column &#039;employee_id&#039; cannot be null (SQL: insert into `employees` (`id`, `employee_id`, `last_

Nameless_0's avatar
Nameless_0's avatar K_Nameless7yrs agoJavaScript
6
1
Last reply by K_Nameless 7yrs ago
shone83's avatar

On checkbox update this error: Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id

I have a table with checkbox where I only need to update just that checkbox, where default value is 0 and boolean in migration. CallCenterController look like this: public function edit($id) { $callCenter = AddMember::findOrFail($id); return view('callcenter.index', compact('callCenter')); } /** * Update the specified resource in storage. * * @param \Illuminate\Ht

shone83's avatar
shone83's avatar Snapey7yrs agoLaravel
34
5
Last reply by Snapey 7yrs ago
amritpa9's avatar

due to my ajax paginationm duplicate meta title tags appearing in google Webmaster

because of ajax pagination google webmaster is showing dupicate meta title tags issue in laravel project,. follow are pages of duplicate title tags issue:- Pendu Song - All Punjabi Song Albums /category/punjabi-song /category/punjabi-song?page=3 /category/punjabi-song?page=5 help me, i know basic of laravel not perfect in,

amritpa9's avatar
amritpa9's avatar amritpa97yrs agoLaravel
2
1
Last reply by amritpa9 7yrs ago
V1nk0's avatar

Caching strategy: cache complete lists of results or cache single objects and result lists with only ids of objects

To make it easier to understand I will translate my problem into this easier example: I have a website with stories and categories. Categories contain stories and stories can be assigned to one or more categories. I'm introducing caching. I have thought of two strategies: Strategy 1: Cache the stories for each category. I cache the result for every category. This will generate

V1nk0's avatar
V1nk0's avatar V1nk08yrs agoLaravel
0
1
jvv8's avatar

I'm doing Lucid Architecture all wrong... advice?

I am using the Lucid framework and I'm struggling with a few concepts. Do I return views from the Job or the Feature or the Controller? Where is the request validated? Do I dissect the request into variables or pass the request along to the Feature/Job I have many joins on most of my front-end requests so in the past I've just used raw queries and hydrated the result into the

jvv8's avatar
jvv8's avatar Mulkave7yrs agoLaravel
5
1
Last reply by Mulkave 7yrs 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.