Skip to content

Blog

Page 4 of 76 - keep going...

Don't forget the third argument to when

What is the opposite of when()?

unless() is the obvious answer, and it is correct. But there is also a quieter answer. when() itself accepts a third callback that runs when the condition is falsy.

May 26, 2026 1 min read #laravel

Validate Everything Including Pagination

There are many reasons why we validate data - whether it’s a Laravel project or any other framework or technology. Sometimes it’s for user or business sanity, other times to keep the application functioning properly. We even do so for security - for both security attacks we know about and hopefully to stop ones we don’t understand.

This is the reason why I reached for validation on pagination requests. This is user input. Just because I don’t understand how it could hurt me doesn’t mean I should ignore it, right?

Let’s validate pagination - easily - in Laravel.

May 26, 2026 2 min read #laravel #security

A cleaner fix for the duplicate ULID problem

In a previous tip, I walked through a duplicate public_id bug caused by Eloquent::replicate() carrying the ULID over to the clone.

The fix I landed on was a replicating hook that overwrites public_id on the new instance.

May 7, 2026 1 min read #laravel

Use PHP Named Parameters for Readability

Having too many parameters for a method signature is a sign of a method that is doing too much. But, what can be done to make this more readable if you’re forced to stick with it? Let’s see an example using named parameters.

Apr 21, 2026 2 min read #php

Laravel 201 Created JSON With Location Header

Each API seems to be different. However, there are some best practices that we should all try to follow.

One of those that I really like is the 201 Created HTTP response. If the object is created immediately, you may even return the full object contents.

In some cases, we don’t have the data or don’t want to return the full payload. We can return null with a location header. Here’s how to do that with Laravel.

Mar 12, 2026 1 min read #laravel

Fixing PhpStorm when Git Stops Responding

PhpStorm suddenly stopped recognizing my git repository. I cleared the cache, restarted the IDE, but nothing helped. I jumped to my terminal, ran git from the command line, and everything worked fine there. Confusing, right?

Let me explain why this happened and how I fixed it for good.

Feb 26, 2026 2 min read #git #macos #phpstorm

Why I'm Not Writing About AI Yet

AI is everywhere - and it has been for the last months… the last year(s)… I even use it now a lot as a tool for my development. So why haven’t I published AI guidance or written about it at all?

It’s really a simple reason. And it’s not what you think probably. I’m not a hater. It’s extreme love of AI and technology that makes me wait. Let me explain.

Feb 18, 2026 3 min read #programming