When structuring a database, similar relationships may repeat, like a Task may be assigned to a User, User Group, or User Role. Is it worth thinking about polymorphic? In this example, let's compare the performance and convenience to use.
Laravel Breeze starter kit registers users and log them in automatically, redirecting to the dashboard. But what if you want the person to log in manually, putting their email and password again after registration?
When do you need to create interfaces in PHP/Laravel? Suppose you have a method with different implementations depending on some condition. In that case, it may be a candidate for an interface, with different classes implementing that interface method differently, depending on that condition. Let me show an example.
When writing automated tests, sometimes you want to repeat the same test multiple times on various data inputs. In Laravel, you can do this easily with data providers and datasets. I will show you a PHPUnit and a Pest example.
One of the typical issues with pagination is if you have more filters with GET parameters on your page. How to keep them from disappearing when the user clicks to visit "/?page=2"?
If you have a Laravel many-to-many relationship and need to sort the Collection by the pivot table value, the query may be complicated. Let's take a look at this example.
Imagine you have a Laravel + Vue project with Posts in the DB but need to show only the first 300 characters of content in the Posts list. Where should you perform that slicing - in Vue or Laravel? Let's compare.
Have you ever used an external API and specified its version? For example, have you noticed the "/v1/" in the URL of "https://api.openai.com/v1/models"? In this tutorial, I will explain how to use similar versioning for our own APIs we create with Laravel.
Experienced developers often advise avoiding static methods in PHP classes. In this tutorial, let me give you a few practical Laravel/PHP examples behind this advice. When are static methods ok, and when it's best to avoid them?
With the release of Laravel 10, you might have noticed that the $dates property on your Model stopped working properly. It has been deprecated in favor of $casts. Let me show you what to do.