Laravel 11.19, weekly updates, and 🔥 deals

Laravel 11.19

There was another release last week reverting a few things and one today bringing us to Laravel 11.19. Here are some highlights from both Laravel 11.18 and 11.19.

  • Apply relation constraints on upsert in #52239
  • Add whereNone to the query builder in #52260
  • Add assertSeeHtml, assertDontSeeHtml, and assertSeeHtmlInOrder in #52285
  • Add assertExactJsonStructure in #52311
  • Add withoutHeader to MakesHttpRequests in #52309
  • Add completeWords flag to Str::limit in #52245

You may review the full branch diff on GitHub for a complete list of changes.

This version bump and update is automated for subscribers to a Shifty Plan. If you don't have one of those, be sure to bump your constraint and run composer update to get the latest features.

Weekly Journal

Last week I live streamed working on a new feature for Shift. I soft-launched it Friday. I still need to write-up a deep dive for the Shift Blog. Hopefully I'll have time to do that later this week.

With the rest of the week I met with potential pairs for a new side-project. In between those, I polished a few rough edges on wppm.io.

Over the weekend I updated a few of the Shift Videos. However, I aquired a bit of a cold. So I'm taking a few days off since I sound hoarse. I'll see how it feels in tomorrow's live stream - where I embark on a crusade to improve Mockery's error messages.

🔥 Tip

In the process of working on the new Shift feature, I found another case where I preferred native PHP array functions (and operators) over collection methods.

Let's consider the following structure:

[[1 => 'a'], [3 => 'c'], [2 => 'b']]

I want it to be:

[1 => 'a', 3 => 'c', 2 => 'b']

In my mind, I was thinking flatten or condense. However, those don't work since they don't preserve the keys. This means mapWithKeys works:

$items->mapWithKeys(fn ($item) => [key($item) => current($item)]);

But the use of key/current felt complex to my eye. There had to be a better way. Maybe there is or maybe there's one waiting to be born.

I don't know it, so I proposed this to some big brains and stumbled upon:

array_replace(...$items);

Now this is complex. But I find it easier read - spread out the individual subarrays and pass them to array_replace.

Let's break it down, first spreading them out:

array_replace([1 => 'a'], [3 => 'c'], [2 => 'b']);

This is obviously less complex. Now we just need to know what array_replace does - it replace items in the first array with items from the other arrays.

Since all my keys are unique, it, effectively, flattens with keys. The result is a single array I want:

[1 => 'a', 3 => 'c', 2 => 'b']