5 years ago

Calculated Fields

Posted 5 years ago by KrayRish

Hello wonderful Laracasts community,

I'm just starting out my Laravel journey, and have a small project I'm using to consolidate the basics. I'm a bit confused about where/how I deal with calculated fields and Eloquent models. I have a model where I initially put all the properties in the database, but then realised that I didn't actually want the user to input half of them since many are calculated.

So my question, is the model the right place to keep calculated fields (and if so, do I just add them as attributes to the model?) or should I use some other abstraction to separate out the logic from the model?

Please sign in or create an account to participate in this conversation.