Laravel 9.46, weekly updates, and 🔥 tip
Laravel 9.46
The new year brings us a new release of Laravel 9.46. Here are the highlights:
- Load schema for in memory databases #45375
- Update
decimal
validation rule to allow signed numbers in 24a48b2 - Output only unique asset / preload tags #45404
- Add
whenHas
andunless
toJsonResource
in #45376, #45419
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
The last few weeks I mostly spent time with the family. However, when I had time during kid naps, I continued working on the outstanding Human Shifts. I'm now all caught up with these and should be able to start on the Laravel 10.x Shift next week.
In the meantime, I'm making some improvements to the Tests Generator and CI Generator. For the CI Generator, there were some GitHub Actions that needed to be bumped. I also went through each of the comments to add more guidance. I've actually been giving conference talks on setting up GitHub Actions for Laravel projects. So I've learned more since creating this Shift.
I hope to finish those changes and start on the Tests Generator later this week. I'm also going to return to live streaming tomorrow with some final tweaks to the --dirty
option I'm been trying to add to Laravel Pint.
🔥 Tip
In working on the CI Generator I'm basically making a large array that I later output as YAML. As such I am manipulating a lot of elements based on the project.
A challenge I stumbled upon was how to insert an element into a nested, associative array. Specifically when I want to determine the index based on a value within the nested array.
For example, when the job step is "Code style" and the project doesn't have one, I need to inject a step above to install pint
.
$steps = [ // ... ['name' => 'Check syntax', 'run' => '...'], ['name' => 'Code style', 'run' => '...'], // ...];
I ended up using array_columns
to effectively map the name, then array_search
to get the index. Since all steps have a name
, I'm guaranteed the indexes match.
$index = array_search('Code style', array_columns($steps, 'name'));array_splice($steps, $index + 1, 0, ['name' => 'Install Pint']);
I'm sure there's some fancy of collection pipeline I could write. But I couldn't think of one and in these cases native PHP array functions are more clear to me.