September 12, 2022

How To Use Dataproviders When Testing Request Validators In Laravel

When writing request validators in Laravel, it is useful to know which incoming data will lead to a validation error, and which data will pass. A convenient way to test this, is to write unit tests that make use of data providers. Data providers can...

Read

July 8, 2020

What is Value Object Casting in Laravel?

Laravel 7 introduced Custom Eloquent Casts. Next to primitive types, such as json, it is also possible to cast values that form a compound to objects. This is an effective way to introduce value objects to your Eloquent models, and make your data more...

Read

Sign up for the newsletter

February 18, 2022

How To Search And View The Data Of An Elasticsearch Index

When working with Elasticsearch, you might want to know what data is actually stored on an index. This article describes some endpoints of the Elasticsearch REST APIs that might help you during...

Read

November 10, 2021

Refactoring Multiple If Statements to Objects

In this article I would like to describe how you can refactor a method that contains multiple if-statements by creating objects with a single responsibility, each making their own assertions. Most...

Read

October 26, 2021

Database Transactions in Laravel with saveOrFail, updateOrFail, and deleteOrFail

When you want to rollback a set of database operations if one of them fails, you can execute them within a database transaction. Laravel provides several techniques to do this. One of them, that I...

Read

May 25, 2021

How to Remove Null Values From a Collection in Laravel

Sometimes, you may end up with a collection that contains null values. Removing those null values from the collection can be done very smoothly with the filter...

Read

May 14, 2021

Sending Laravel Notifications Without Notifiable

Notifications in Laravel are typically used to notify users in your application. Users do not have to be the App\Models\User model, but can be any model that includes the...

Read

February 11, 2021

Six Ways to Get Raw SQL Output From Query Builder in Laravel

When working with Laravel, you will probably use the query builder in order to create and run database queries. Sometimes you want to see the raw SQL output of a query, for example when you are...

Read