M
MeshWorld.
Back to Tags
Topic View

#Eloquent.

12 posts filed under this topic.

Laravel 5 min read

Nested Eager Loading in Laravel Explained

Learn how nested eager loading in Laravel Eloquent reduces database queries for deeply related models. Covers syntax, conditional loading, practical examples, and when to use it.

Vishnu
Vishnu
Laravel 5 min read

Update a Laravel Record Without Touching Timestamps

Four ways to update a Laravel Eloquent record without changing updated_at: timestamps property, saveQuietly(), withoutTimestamps(), and the query builder. With version notes.

Vishnu
Vishnu
Laravel 5 min read

Create a Laravel Collection from an Array

Learn how to wrap a plain PHP array in a Laravel Collection using collect() or new Collection(). Covers filter, map, sum, and groupBy with real examples.

Vishnu
Vishnu
Laravel 5 min read

Get Last 30 Days Records in Laravel with Carbon

Three ways to query the last 30 days of records in Laravel using Carbon — simple where(), whereBetween(), and a reusable query scope. Works on Laravel 10, 11, and 12.

Vishnu
Vishnu
Laravel 5 min read

Laravel Eloquent whereTime() Method Explained

Learn how Laravel's whereTime() method filters records by the time portion of a datetime column. Covers syntax, all operators, and practical examples for time-based queries.

Vishnu
Vishnu
Laravel 5 min read

Laravel Eloquent whereDate() Method Explained

Learn how Laravel's whereDate() method filters records by date, ignoring the time component. Covers syntax, operators, examples, and why raw where() fails for dates.

Vishnu
Vishnu
Laravel 5 min read

Laravel firstOrCreate(): Find or Create a Record

Learn how Laravel's firstOrCreate() finds the first matching record or creates a new one automatically. Covers syntax, parameters, real examples, and comparison with firstOrNew().

Vishnu
Vishnu
Laravel 5 min read

Laravel firstOrNew(): Find or Prepare a Record

Learn how Laravel's firstOrNew() finds the first matching record or returns an unsaved model instance. Covers syntax, when to use it over firstOrCreate(), and real examples.

Vishnu
Vishnu
Laravel 5 min read

Move Records Between Tables in Laravel

How to move a database record from one table to another in Laravel using replicate(), setTable(), and DB::transaction() to keep the operation atomic and safe.

Vishnu
Vishnu
Laravel 5 min read

Route Model Binding in Laravel Explained

Route model binding in Laravel automatically resolves Eloquent models from URL parameters. Covers implicit binding, custom keys, scoped bindings, and soft deletes.

Vishnu
Vishnu
Laravel 5 min read

Change Laravel Model Timestamp Column Names

How to rename created_at and updated_at in a Laravel Eloquent model using CREATED_AT and UPDATED_AT constants. Covers disabling timestamps and custom date formats too.

Vishnu
Vishnu
Laravel 5 min read

Get an Array of IDs from an Eloquent Collection

Three ways to extract an array of IDs from a Laravel Eloquent collection: pluck(), modelKeys(), and querying direct. Covers when to use each and performance considerations.

Vishnu
Vishnu