I am using the appends property (and associated getter methods) to load additional information on a model in Laravel 5.5. However, one of the appends (percentage) depends on the other two appends (current_score and maximum_score) already having been loaded and calculated.
What this means, is that in order to include percentage as an append and have that property be accurate, the maximum_score and current_score properties need to be calculated first.
In other words, if I write my appends array like so:
protected $appends = [
'maximum_score',
'current_score',
'score_percentage',
];
Can I reliably know that that order will be respected? IE, can I know that the maximum_score and current_score properties will always be set before score_percentage, allowing me to use them both to calculate the percentage? Or is there some other way I should be handling this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire