The new @class Blade directive in Laravel 8.x

1 · Amit Merchant · July 31, 2021, 2:22 p.m.
Sometimes, the biggest sign that shows that a framework is maturing is when it has multiple ways of doing the same thing. Laravel, being one of these frameworks, is no exception. For instance, in Blade templates, if you want to add HTML classes conditionally, you can do this by using the class method of the component’s “attribute bag”. The attribute bag is available through the $attributes variable inside the Blade component. So, if you want to add, for instance, an error class bg-red conditiona...