Join 25,000+ Laravel Developers and join the free Laravel Newsletter
Laravel Tutorials / February 13, 2015

Laravel 5 Eloquent attribute casting

Jens Segers wrote about the new Eloquent attribute casting and how he has been using it:

For me personally, this will be especially useful when working with boolean values. Boolean values are usually stored as a TINYINT in the database, and when Eloquent fetches the model again, they are returned as a “1” or “0” string. “Luckily” for us, PHP does some type juggling and implicitly converts it to the correct boolean values.

Building rich client side apps with this is really going to be awesome. No more parseInt() or crazy checks to see what data you are getting. I’m a big fan of this feature.

This appeared first on Laravel News

Visit Resource →

Laravel News Partners

Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.