Laravel 12.10, weekly updates, and weekly tip
Laravel 12.10
Couple patch releases last week and a few new features this week brings us to Laravel 12.10.0.
- Add
Conditionable
toFluent
in #55455 - Allow mapping
Eloquent
attributes using the collection cast in #55383 - Fix group imports in Blade
@use
directive in #55461 - Improve performance of
Arr::dot
up to 300x in #55495 - Update compiled views only if they actually changed in #55450
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 introduced Livewire to the laravelshift.com project. Prior I had only been using Alpine. There really hadn't been a need to move to Livewire. Plus, this project started 10 years ago. Livewire didn't exist back then. So it's taken a bit more than normal to introduce it.
The main driver is my move to Stripe's Billing Portal. Due to its webhook nature, having small Livewire components on page will be cleaner than a bunch of Alpine (JavaScript) code. I realize Livewire uses Alpine. Beyond the polling, being able to simply use Blade still makes it cleaner.
This week I hope to finish that up, as well as implement Stripe Checkout for new customers. This will be a bit of a trail to verify everything before rolling it out to all orders. I'm always a bit nervous when changing anything regarding the order flow.
I also got BaseCode back from the printer. I always wanted one for my bookshelf. I ended up printing 50. Some are for my high school bookshop (they requested 20). So, I'm going to build a little Laravel/Cashier app in this week's livestream to sell the remaining copies. Likely with a custom signed option.
Weekly Tip
This was added a few weeks ago in Laravel 12.8, but I hadn't used it yet. The new toResource
and toResourceCollection
methods added to Eloquent help streamline code. You know I love streamlining code. And leveraging Laravel conventions. This does both.
Here are some before and after snippets using these new methods.
// Resource// beforereturn new UserResource(User::findOrFail($id));// afterreturn User::findOrFail($id)->toResource(); // Resource Collections// beforereturn UserResource::collection(User::all());// afterreturn User::all()->toResourceCollection();
I might make a Workbench task to streamline these in the coming weeks.