Closed valorin closed 12 months ago
@valorin cheers! i have a feeling this may have been changed in the core codebase, as I'm fairly certain I duplicated the first bit of it. Something in the back of my mind is saying that I felt it was weird to begin with (placing relations over attributes).
Happy to change this - it should definitely maintain the same behaviour as Eloquent.
any chance this will be updated?
Certainly, soon as I have time.
Anyone who is surprised by this, please have a look at the new getAttribute
function code (10.x): https://github.com/laravel/framework/blob/b4ab62986000eaa411a22dbeb112b21c10420fdc/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L428
This is resolved in the coming 11.0 release.
I've just noticed an interesting discrepancy in
getAttribute()
between how theCamelCasing
trait works and the original Eloquent Model.Consider the Eloquent Model function:
Now look at CamelCasing:
Eloquent allows attributes (even read-only ones) precedence over relations. CamelCasing favours relationships first.
It seems to me that following Eloquence's order of preference would be a good idea, so the behaviour is consistent between both.