Blade component gotcha

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A gotcha in Laravel's Blade anonymous components causes Eloquent models (or any object implementing `__toString`) to be silently serialized to JSON every time the component is instantiated. This happens inside the `sanitizeComponentAttribute` function in the Blade compiler. The workaround is to use class-based components

2m read timeFrom hbgl.dev
Post cover image

Sort: