Lifetime access is $100 off. Available for a limited time.Join here →

Articles

Showing 10 posts
May 19th, 2024

Eloquent Events on Pivot Tables

I recently needed to listen to events on a pivot table within the Codecourse codebase. When a user resets progress for a course, and all the episodes they've completed are detached, episode progress (stored in Redis) should be removed.

Author
Alex Garrett-Smith
Laravel
Eloquent
May 18th, 2024

Using the Booted Method Inside Traits in Laravel

Extracting some functionality to a trait but need to use the static booted method within that trait? Here's how.

Author
Alex Garrett-Smith
Eloquent
Laravel
May 17th, 2024

Disable Global Scopes in Laravel Nova

If you're using global scopes in Laravel, these will likely affect your admin panel. Here's how to remove them.

Author
Alex Garrett-Smith
Laravel
May 7th, 2024

Your Guide to Every Official Laravel Package and Service

The Laravel Ecosystem is big. So big that when you start working with it, it's sometimes difficult to know which first-party packages are available, and which ones to reach for.

Author
Alex Garrett-Smith
Laravel
April 22nd, 2024

Resetting Laravel Collection Keys After Filtering

I recently filtered a Laravel collection that was due to be output as JSON. To my surprise, it didn't work as intended. Here's what happened, and how to resolve it!

Author
Alex Garrett-Smith
Laravel
April 19th, 2024

How to disable Laravel Scout for Nova Resources

For whatever reason, you may need to disable Laravel Nova automatically using Scout when searching. Here's how.

Author
Alex Garrett-Smith
Laravel
April 18th, 2024

How to get the table name from a model in Laravel

Table names don't change often, but it's still nice to reference table names directly from your Eloquent models, so you don't end up with a bunch of hardcoded table names.

Author
Alex Garrett-Smith
Eloquent
Laravel
March 14th, 2024

How to Paginate a Laravel Collection

If you're merging multiple models into a Laravel collection or just have a collection of data you need to paginate, here's an easy, clean way to do it.

Author
Alex Garrett-Smith
Laravel
Eloquent
March 11th, 2024

Generate Open Graph Social Sharing Images With Laravel

Here's the technique I use to design, generate, cache and serve social images for the article you're reading right now.

Author
Alex Garrett-Smith
Laravel
March 8th, 2024

Counting Unique Views in Laravel with Redis

If you want to count unique views for models in your Laravel apps, you might reach for a database table. There's a much easier and faster way though, using Redis.

Author
Alex Garrett-Smith
Laravel
Redis

Tags