Laravel Pro Tips
So I heard y'all like types in your ORM.
Laravel allows you to define casts at the model level to handle casting values to their native types.
More interestingly, it also allows you to define them at query time, so you're not sacrificing the power of SQL 💅
You can encrypt and decrypt model attributes with casting.
When casting "encrypted", Laravel will decrypt the value on retrieval and encrypt it when saving.
🌶️ #Laravel Tip: When using an 𝗮𝗰𝗰𝗲𝘀𝘀𝗼𝗿 remember to always cast the data to it's real type, even though you're casting it inside $𝗰𝗮𝘀𝘁𝘀.
Both casts and accessors work on the actual data 🤔
Bilal Haidar - Available 4 Laravel gigs
⚡️Using enums is a joy with Laravel.
For example, you can cast string Eloquent properties to enum values using the casts property:
No articles were found.