Laravel 8.61, weekly updates, and 🔥 tip

Laravel 8.61

There was a patch release last week (Laravel 8.60) which brings us to Laravel 8.61.0 this week.

Here are the highlights:

  • Revert #38552
  • Add the valueOrFail to Eloquent builder in #38707
  • Compare custom_date and immutable_date using date comparison in #38720
  • Add --policy to make:model in #38725
  • Provide psr/simple-cache-implementation in #38767
  • Allow tests to utilize the null Log driver in #38785
  • Add deleteOrFail to Model in #38784
  • Add assertModelExists and assertModelMissing in #38766

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 focused mostly on the Shifty Plan dashboard. I always mean to give this section more love, but it gets deprioritized over building new things.

However, subscriptions are becoming a larger percentage of revenue. So I want to make sure subscribers are happy and have the features they need.

After a quick chat with Matt Stauffer about some of the things he uses to manage the many projects at Tighten, we came up with a list of tweaks.

Here are some of the things Jess and I resolved last week:

  • Filling more form fields by pasting in a clone URL.
  • New preference for customizing the redirection after logging in to Shift. For example, to go to the Shifty Plan dashboard instead of Recent Shifts.
  • Sorting Shifty Plan repositories by name or version.
  • Iconography for Shift Plan repositories which are behind or running unsupported versions of Laravel.

There are a few more tweaks we want to make to the Shifty Plans sections. We plan to continue to focus on those this week.

With the remainder of last week I added one final enhancement to the Pest Converter. The initial MVP was built under the assumption that you were converting a PHPUnit test suite to Pest. However, some projects already have a mixed test suite.

I updated the Pest Converter to read any existing configuration, as well as review any configuration within the converted tests. It then merges these together for an optimized set of uses and updates all files accordingly.

This took a solid day to implement, adding to the overall time investment building the Pest Converter. Totally worth it for the final version. But I do talk more about this in a personal blog post about building a PHPUnit to Pest Converter in one week.

🔥 Tip

When working to optimize the uses statements, I created a registry of files and their corresponding uses. I then needed to transpose (or flip) these key/values.

It seemed like something that I could do with collections. However, I ended up staring at the docs for a good 30 minutes. So I ended up posting on Twitter.

In this case, here is a collection chain which ultimately flipped the dataset:

1$flipped = collect($registry)
2 ->map(function ($uses, $classname) {
3 return collect($uses)->map(function ($use) use ($classname) {
4 return [
5 'use' => $use,
6 'class' => $classname,
7 ];
8 });
9 })
10 ->flatten(1)
11 ->mapToGroups(function ($item) {
12 return [$item['use'] => $item['class']];
13 });

And here is a foreach loop to do the same:

1$flipped = [];
2foreach ($registry as $class => $uses) {
3 foreach ($uses as $use) {
4 $flipped[$use][] = $class;
5 }
6}

So, nothing wrong with challenging yourself to use collections. But sometimes a good old foreach still provides a fast, straightforward solution. 🔥