# Database

Entries tagged with "Database".

Eloquent Secrets Intermediate

Model::withoutTimestamps()

Execute operations without touching the updated_at column, useful for bulk imports and data migrations.

Database
Eloquent Secrets Advanced

DB::whenQueryingForLongerThan()

Get notified when your cumulative database query time exceeds a threshold during a single request.

Database Performance Debugging
Artisan & CLI Beginner

artisan model:show

Inspect any Eloquent model's columns, relationships, observers, and policy from the command line.

Database Debugging
Hidden Methods Intermediate

Collection::sole()

Get exactly one matching item from a collection — or throw an exception. A stricter alternative to first().

Collections Database
Eloquent Secrets Intermediate

Model::withoutEvents()

Silence all model events within a closure — perfect for seeding, imports, and data migrations where observers would cause side-effects.

Database Events
Eloquent Secrets Intermediate

Model::toQuery()

Convert an Eloquent Collection back into a query builder scoped to those exact model IDs — bridging collections and queries.

Collections Database
Eloquent Secrets Intermediate

Model::withAggregate()

Load aggregated values from related models as attributes — count, sum, min, max, avg — in a single query without loading the relation.

Database Performance