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

Articles

Showing 6 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
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 7th, 2024

Checking for Insert Collisions in Laravel

When you fill a database row with any kind of random or generated data, checking for collisions is a great idea.

Author
Alex Garrett-Smith
Laravel
Eloquent
January 29th, 2022

Clear orderBy in Laravel's Eloquent Builder

If you've tried to use `orderBy` on a previously ordered query in Laravel, you'll probably find it doesn't work. There's a great reason for that, which we'll explain at the end of the post.

Author
Alex Garrett-Smith
Laravel
Eloquent

Tags