Hello!
I would like to learn how to integrate custom logic to a model property.
For example, some records of the database table contain an empty value in some column. This empty value means “use default”. I would like to override this empty value with a default one inside Eloquent model.
I.e. when I load such record via Eloquent model, and when I read such property, I would like to get some value instead of an empty string. How is it possible?
And also on write. When I write some value to a model’s property, and this value is equal to some default value, an empty value should be saved to the database.
Thank you!
Check out accessors and mutators:
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community