Laravel 8.46, weekly updates, and 🔥 tip
Laravel 8.46
So there was a late week release last week. This week we resume regularly scheduled programming, bringing us to 8.46.
Here are the highlights:
- Create custom Notification stubs in #37584
- Automatic object formatting for Blade echo statements in #37478
- Allow connecting to read or write connections with the db command in #37530
- Add
assertDownload
test method in #37532 - Add
RequestSent
andResponseReceived
HTTP events in #37572 - Fire a
trashed
model event and listener for broadcasting events in #37618 - Introduce
Conditionable
trait on validation rules in #37504
You may review the full branch diff on GitHub for a complete list of changes.
This minor 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 worked on the checkout flow for the secret project. Tomorrow, the project will not be so secret as I plan to tweet about the motivation for making it and announce the beta release (next week).
I did tweet a little screenshot of the secret project last week. I plan to twwet a few more this week and likely do some demos and "behind the scenes" live-streams next week.
I also updated the Laravel 8.x Shift to include automation for converting to class based routes as well as merge the deprecated $dates
property into $casts
. Both of which were done by the Laravel Fixer and available from the Workbench.
This week I had a few Human Shifts come in. So I'll finish out the week focusing on those so I'm free for the launch next week.
🔥 Tip
This week I want to look more closely at the new Stringable
addition. This effectively allows you to register "formatters" for certain object types when outputting data in Blade templates.
Borrowing the classic money example from the Laravel docs, in Blade we'd simply output something like:
1<span>Buy now for {{ $product->price }}</span>
Now by registering an "echo handler", instead of seeing the raw value or receiving an error, we may control how Blade outputs this object. To do so, we register a callback for that object type:
1Blade::stringable(function (Money $money) {2 return $money->formatTo('en_US');3});
To really bring everything together, we could also custom cast the price
attribute in our Product
model to a Money
object:
1protected $casts = [2 'price' => Money::class,3];