laravelmastery
SnippetsArticlesSeriesNews

Snippets

Paste-ready Laravel you can drop into a service provider, a job, or a test. Each one is short enough to read in a minute, and written for the code you already ship.

All EloquentQueriesQueuesTestingHTTPArtisanFactories

5 snippets

Refuse attributes a model will throw away

Catch a typo in a fillable list during development, before the column quietly stays null.

Eloquent · Guard rail

Read

Catch N+1 queries before your users do

Turn lazy loading into an exception outside production, so missing eager loads fail loudly in development and tests.

Eloquent · Snippet of the week

Read

Listen to one request’s queries

Drop this in a local route while you hunt an unexpected query.

Eloquent · Debugging

Read

Query by relationship, not by ID

Reads like English and keeps foreign keys out of your controllers.

Eloquent · Queries

Read

Inspect a model from the terminal

See attributes, casts, relations and observers in one view.

Eloquent · Artisan

Read

Get the Friday email

One snippet and the week’s Laravel news, in your inbox every Friday morning. Unsubscribe whenever you like.

laravelmastery

Practical Laravel learning for working developers, made in the UK.

Learn

  • Snippets
  • Articles
  • Series

Stay current

  • News
  • Friday email
  • RSS feed

Company

  • About
  • Privacy
  • Terms
© 2026 Laravel Mastery. Independent and not affiliated with Laravel Holdings Inc.Designed and built by Half Shell Studios

We remember the videos you watch, where you left off, and which series lessons you mark as read, against this connection’s address. Nothing is stored until you agree.