Pluck method does not respect Attribute return type mutators #54114
Unanswered
MattBradleyDev
asked this question in
Q&A
Replies: 1 comment
-
Hi. This seems like a bug/partial implementation for the new version of mutators. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When using the magic accessor methods on a model then the
->pluck(...)
method will apply correctly on the returned instance.However, when using the
Attribute
return type this is not applied through the->pluck(...)
method.Looking into the
pluck
method withinsrc/Illuminate/Database/Eloquent/Builder.php
the$this->model->hasGetMutator
method is called, checking only for the magic name which then forces you to get the model collection and then subsequently plucking from there, rather than directly from the database.src/Illuminate/Database/Eloquent/Concerns/HasAttributes::hasGetMutator
This seems like it would be fixed by applying the
$this->model->hasAttributeGetMutator($column)
check alongside$this->model->hasGetMutator
in order to recognise these other attributes.Is there a reason that this is not implemented this way?
Beta Was this translation helpful? Give feedback.
All reactions