These posts are about something Laravel related.
November 21, 2023
When you want to update a record and create it when it doesn't exist, you can use the
updateOrInsert method in Laravel.
The so-called "upsert" methods....
October 25, 2023
In Laravel it is seen as good practice to dependency inject the
Illuminuate\Http\Request object in your methods when possible, instead of using the
October 20, 2023
WebP is a modern image format for the web that is developed by Google. It is based on the VP8 video format, and provides superior compression. Because of these qualities, it is intended to replace...Read
September 12, 2022
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...Read
October 26, 2021
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
Sometimes, you may end up with a collection that contains
null values from the collection can be done very smoothly with the
May 14, 2021
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...
February 11, 2021
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
November 25, 2020
Since Laravel 8.16, it is possible to split a collection into chunks in two different ways. The first one, that already existed, is the split method: This method breaks a collection into a...Read
November 16, 2020
When creating a catch-all route in Laravel, you might encounter conflicts with others routes in your application. In this post I would like to describe how you can resolve some of these conflicts....Read
October 1, 2020
When you want to show a list of all registered routes in your application, you can use the
php artisan route:list command.
The output of this command can be a bit confusing when you are...
September 1, 2020
Sometimes you want to call an Artisan command from your code. Some commands show data. How do you read the data that an Artisan command may show in the console? For example, you could have a...Read
August 18, 2020
When you need to update a resource in Laravel, you might decide to use the
update or the
Let's take a look at the source code of the
July 8, 2020
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...Read
June 17, 2020
With configuration caching you can bundle all configuration files, to be loaded faster by Laravel.
When you run
php artisan config:cache, a new file will be created in...
May 16, 2020
Since 7.x, Laravel provides a very compact syntax for creating foreign key constraints with the
In this post we will give a short demonstration of this syntax, and we...
April 24, 2020
Recently I stumbled upon a nested query in a Laravel project. It was written like this: You might have seen a comparable nested query in the code you had to work on, and you probably agree that...Read
April 19, 2020
Laravel 7 came with a new feature, stub customization. Stub customization gives the ability to modify the stub files that are used when creating classes such as controllers and tests with the...Read
March 11, 2020
Laravel 7 has an excellent new feature, called fluent string operations. It provides an "object-oriented interface for working with string values", e.g. becomes In this post I would like to...Read
February 21, 2020
A guide on how to install Elasticsearch on MacOS in order to use it as a driver for Laravel ScoutRead
February 1, 2020
The Laravel service container is called "a powerful tool for managing class dependencies and performing dependency injection". In this post, we will look at a possible use case of the service...Read
January 23, 2020
In most cases, when writing policies in Laravel, you only pass one argument to a policy method, since the authenticated user is already available through dependency injection and no other resources...Read
December 20, 2019
Just recently I discovered you can apply
where statements to the
exists validation rules in Laravel, without using a closure.
This means you can...
December 15, 2019
One of the cool things of Laravel's validation rules, is that you can apply certain rules to different data types. When checking the minimum and maximum size of an array, you can use the...Read