Laravel Tips
  • Home
  • PHP
  • Laravel
    • Models
    • Helpers
    • Security
    • Laravel Eloquent
    • Laravel Updates
  • MySQL
  • CheatSheet
  • About
  • Contact

Type and hit Enter to search

Laravel Tips
  • Home
  • PHP
  • Laravel
    • Models
    • Helpers
    • Security
    • Laravel Eloquent
    • Laravel Updates
  • MySQL
  • CheatSheet
  • About
  • Contact

Follow Us

Laravel Tips
  • Home
  • PHP
  • Laravel
    • Models
    • Helpers
    • Security
    • Laravel Eloquent
    • Laravel Updates
  • MySQL
  • CheatSheet
  • About
  • Contact

Type and hit Enter to search

Laravel Tips
  • Home
  • PHP
  • Laravel
    • Models
    • Helpers
    • Security
    • Laravel Eloquent
    • Laravel Updates
  • MySQL
  • CheatSheet
  • About
  • Contact

Follow Us

Laravel

Laravel Development Services: The Complete Guide to Building Scalable Web Applications in 2026

Table of Contents Introduction What Is Laravel? Why Choose Laravel for Web Development What Are...

Read More
How to Check Laravel Version
How to Check Laravel Version in CMD: A Step-by-Step Guide
November 27, 2024
How to check the Laravel version?
How to check the Laravel version?
December 17, 2023

Recent Tips

The Ultimate Guide to PDF Upload Using Vue.js

The Ultimate Guide to PDF Upload Using Vue.js

Jagdish Chaudhary, CSPO®️
December 1, 2023
How to Choose the Right Laravel Development Company

How to Choose the Right Laravel Development Company

Jagdish Chaudhary, CSPO®️
November 17, 2023
How to Implement Email Verification in Laravel Breeze

How to Implement Email Verification in Laravel Breeze

Jagdish Chaudhary, CSPO®️
October 23, 2023
Laravel Where IN

How to Use Laravel Where In to Filter Your Database Queries

Jagdish Chaudhary, CSPO®️
October 21, 2023
How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps

How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps

Jagdish Chaudhary, CSPO®️
October 11, 2023
How to Delete Pivot Tables in Laravel

How to Delete Pivot Tables in Laravel: A Comprehensive Guide

Jagdish Chaudhary, CSPO®️
September 29, 2023

Recent Tips

Laravel Where IN
21 Oct
Laravel Eloquent

How to Use Laravel Where In to Filter Your Database Queries

How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps
11 Oct
Laravel

How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps

How to Delete Pivot Tables in Laravel
29 Sep
Laravel

How to Delete Pivot Tables in Laravel: A Comprehensive Guide

How to fix the Could Not Find Driver error in Laravel
23 Sep
Laravel

How to fix the “Could Not Find Driver” error in Laravel

More Posts

Instagram Feed

laraveltips.io

🚀 Laravel 12 just made query writing feel like che 🚀 Laravel 12 just made query writing feel like cheating 😎

nestedWhere() = cleaner code, faster performance, fewer headaches.

Say goodbye to messy closures 👋 and hello to elegant one-liners 💻

💡 Learn the full breakdown + code examples on my website 👇
🌐 laraveltips.io

—
🧠 Follow @laraveltips.io for Laravel gems, web dev hacks & real-world tutorials ⚡

#laravel12 #laraveltips #webdevelopment #phpdevelopers #laravelcommunity #cleancode #fullstackdev #codingdaily #laravelindia #codesmart #programminglife #devcommunity #techreels #codebetter #webdevjourney #softwareengineer #laraveldevelopers #codingvibes #WebDevIndia #LaravelNation #devlifestyle #codewithstyle #techcreators
Are you a talented Laravel PHP developer? 🖥️💼 We’r Are you a talented Laravel PHP developer? 🖥️💼 We’re on the lookout for passionate individuals to join our Laraveltips.io team! 🤝

Join us in crafting the future of web development and let your skills shine. 🌐✨

Apply today and be a part of something extraordinary. 📩👩‍💻

#LaravelJobs #WebDevelopment #JoinOurTeam #TechCareer #Innovation #CodeWithUs #laraveltips #laravel #php #hiring
Eager loading fixed your query count. It never fix Eager loading fixed your query count. It never fixed the hydration.

You write User::with('orders') so a table can show a last order date. Laravel runs two queries, then builds every Order model behind them. Fifty users with forty orders each is 2,000 objects created, cast and held in memory so you can read fifty timestamps.

A select subquery asks the database for the value instead of the rows.

User::addSelect(['last_order_at' => Order::select('created_at')
 ->whereColumn('user_id', 'users.id')
 ->latest()
 ->limit(1)])

Three rules that make it work:

1. One column, one row. select() a single column and limit(1), or the database rejects it.
 2. Correlate with whereColumn and qualify the outer side as users.id. Plain where() compares against the literal string and quietly returns nothing.
 3. What comes back is an attribute, not a relation. Cast it with withCasts(['last_order_at' => 'datetime']).

Then the payoff eager loading cannot reach: pass the same subquery to orderByDesc and you can sort a paginated list by a relation's value. Sorting the collection only reorders the page you already fetched, so your most recent customer stays on page 12.

One caveat, stated plainly: the subquery runs per candidate row, so index orders on (user_id, created_at). Without that index you have moved the cost, not removed it.

Keep with() when you need several fields, an accessor, or more than one related row. Reach for the subquery when you need one value.

Where in your codebase are you loading whole rows to read a single field?

#laravel #eloquent #php #backend #database sql performance laraveltips
⚽️ Ever feel like your Laravel mistakes come back ⚽️ Ever feel like your Laravel mistakes come back to hit you… hard? 💥 Don’t let broken routes knock you out! 🛑 Here’s a quick fix for 404 errors that’ll keep your code on target! 🎯 #LaravelTips #CodeFix #404Error #DeveloperLife
Diwali Celebration With Team, Laravel Tips. @preci Diwali Celebration With Team, Laravel Tips. @precise_developers #team #diwali #diwalidecorations 

@jeet_sharma7 
@sanskar_3003 
@beats_by_krina
Controller Route Groups - this simple structure im Controller Route Groups - this simple structure improves maintainability and saves time while scaling your Laravel app. ⚡

💬 Have you used Controller Route Groups before? Drop a ⚙️ in the comments if you love clean code!

👉 Follow us for more Laravel tips - @laraveltips.io 
🌐 Visit our website for more detailed tutorials and guides! - laraveltips.io

#laravel #laraveltips #laraveldeveloper #php #webdevelopment #codewithlaravel #backenddeveloper #codingtips #cleancode #developerlife #programmer #webdev #learnlaravel
7 Essential Concepts You Can't Afford to Miss! If 7 Essential Concepts You Can't Afford to Miss! If You are planning to start Learning #reactjs 

 #laraveltips #php #devops #reactnative #javascript #webdeveloper #treanding
Ever had to find common elements between two colle Ever had to find common elements between two collections in Laravel? 
Check out this neat trick with the `intersect()` method! Just saved myself tons of time. 
Happy coding! 💻✨ #Laravel #CodingLife #PHP #DevHacks #laraveltips #programming
🚀 We’re on top of the world! 🌍✨ No. 1 on Google fo 🚀 We’re on top of the world! 🌍✨ No. 1 on Google for “Laravel API Gateway”! 🥇 Just search it yourself and see! 😎💻

At LaravelTips.io, we’re thrilled to be your go-to source for all things Laravel. 🤝 Our mission? To empower developers, one tip at a time! 🛠️📚

👉 Want to turbocharge your Laravel skills? Dive into our treasure trove of tutorials and resources. 🚀📖

Explore the world of Laravel with us! Click the link in our bio now! 🔗👆

Don’t miss out on the Laravel revolution! Join us today. 🌟💻

#Laravel #APIGateway #Programming #WebDev #CodeLife #TechSavvy #DeveloperCommunity #CodingNinja #WebDevelopment #LearnToCode #DevLife #DevTools #LaravelTips #DevResources #TopGoogleRanking #TechGurus #ExploreLaravel
Follow on Instagram

Follow Us

Linkedin Twitter Facebook Instagram

Laravel Tips

How to Implement Email Verification in Laravel Breeze
How to Implement Email Verification in Laravel Breeze
Jagdish Chaudhary, CSPO®️
How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps
How to Use Agora Web SDK to Add Real-Time Video and Audio to Laravel Apps
Jagdish Chaudhary, CSPO®️
How to Delete Pivot Tables in Laravel
How to Delete Pivot Tables in Laravel: A Comprehensive Guide
Jagdish Chaudhary, CSPO®️
How to fix the Could Not Find Driver error in Laravel
How to fix the “Could Not Find Driver” error in Laravel
Jagdish Chaudhary, CSPO®️
Load More

Featured Tips

LaravelTips Array Helpers
Boost Your Laravel skills with these powerful Array Helper functions! 
Jagdish Chaudhary, CSPO®️
January 25, 2023
Laravel request lifecycle
Laravel Request Lifecycle
Jagdish Chaudhary, CSPO®️
February 20, 2023
loop/entry/iteration is first or last,
Check if the current loop/entry/iteration is first or last,
Jagdish Chaudhary, CSPO®️
February 24, 2023
Don't Break Your Laravel Code, Avoid ENV calls 1
Laravel Best Practices: Limiting env Calls to Config Files for Better Performance and Stability
Jagdish Chaudhary, CSPO®️
February 26, 2023
How to Simplify Laravel Development with Docker
How to Simplify Laravel Development with Docker
Jagdish Chaudhary, CSPO®️
February 28, 2023
Exploring Advanced Subdomain Routing Techniques in Laravel: A Complete Tutorial
Exploring Advanced Subdomain Routing Techniques in Laravel: A Complete Tutorial
Jagdish Chaudhary, CSPO®️
March 1, 2023
Laravel Tips
  • PHP
  • Laravel
  • Models
  • Helpers
  • Security
  • MySQL
  • Cheatsheet
  • Helpers
  • Contact
Instagram Facebook Linkedin Twitter

Precise Developers © 2026. All Rights Reserved.