Suman Shrestha

Snippets | Suman Shrestha

Code Snippets & Insights

54 articles

Optimizing Eloquent Relationships

Using hasOneThrough and hasManyThrough to simplify access intermediate data in Laravel.

Floating Point Validation

Validating floating point numbers in JSON payloads is tricky. Learn about the 'decimal' rule improvements.

Mastering Omit and Include Validation Rules

Handle exclusion logic cleanly in Laravel validation without complex conditional callbacks.

SQLite by Default

Why Laravel 11 chose SQLite as the default database for new applications and why it is production-ready for many use cases.

The Defer Helper

Use the defer() helper to execute code after the HTTP response has been sent to the user, without setting up a queue.

Laravel Prompts

Enhance your Artisan commands with Laravel Prompts, a user-friendly way to gather input in the CLI.

Native Eager Load Limit

Laravel 11 brings native support for limiting eager loaded relationships, fixing a long-standing "n+1 with limit" issue.

New Artisan Make Commands

Laravel 11 adds helpful artisan commands like make:class, make:enum, and make:interface to speed up your workflow.

Simplifying Config Files in Laravel 11

Laravel 11 config files are empty by default. Learn how to publish only what you need to keep your app clean.

Using Context for Request Tracing

Learn about the new Context service in Laravel 11 to pass information through the request lifecycle, perfect for logging trace IDs.

Laravel Reverb Basics

Introduction to Laravel Reverb, the new first-party WebSocket server for Laravel applications introduced in 2024.

Graceful Encryption Key Rotation

Laravel 11 allows you to rotate your APP_KEY without logging out all users or invalidating all encrypted data.

Per-Second Rate Limiting

Laravel 11 finally adds support for per-second rate limiting, allowing for more granular API controls.

The Once Helper for Memoization

Use the new once() helper in Laravel 11 to easily cache the result of a usage for the duration of the request.

Defining Schedule in Routes Console

In Laravel 11, the Console Kernel is gone. Learn how to define your scheduled tasks directly in routes/console.php.

Loading more articles...

-

Need one on one help with Laravel and its ecosystem?

Talk to me now if you need my help. Click here