Blade stringable to handle objects centrally in Laravel 8.x

1 · Amit Merchant · May 31, 2021, 6:21 p.m.
Wouldn’t it be useful if you could define a certain action that should be performed every time your Blade templates encounter objects of a specific class? So, for instance, let’s say when working with libraries such as Carbon, it’s often the case where you would want to format it in a certain way throughout your application. Normally, if you want to format the date in a specific format for a Carbon instance, you could do it in Blade templates like so. {{ $post->created_at->format('d-m-Y') }} Th...