Added in Laravel 11, incrementOrCreate is a method to create a record uniquely based on a pre-defined array.
This mass assignment error is a really common one when working with Laravel. Here's how to fix the inability to insert/update records.
If you have a potentially existing record and need to update it if it exists or create it if it doesn't. Here's how!
In this article, I'll show you how to set up casts for pivot table columns in your Laravel relationships.
There are several ways to get the row count from your database with Eloquent in Laravel. Let's cover the basics and then look at a much better solution when counting on related models — using aggregates at the database level.
Laravel doesn't have built-in support to fetch next and previous records, but adding a couple of helper methods to your model does the trick.
Ordering in Laravel is pretty straightforward, but you can use a few other techniques to make the most of Eloquent's ordering abilities. Let's cover everything you should know about ordering queries with Laravel!
If, for any reason, you need to get the fillable fields from a Laravel model, it's pretty straightforward.
It's pretty straightforward to use Eloquent outside of the Laravel Framework. Let's look at all the steps to get it working, whether you want to pull it into another framework or use it in procedural code.
Laravel doesn't support has many through pivot relationships out the box, but we can still achieve this manually with a pivot model.