Skip to content

Display custom attribute to user while using select2_from_ajax field with Fetch and InlineCreation #1147

Closed Answered by pxpm
GregaUNK asked this question in Q&A (Help)
Discussion options

You must be logged in to vote

Hey @GregaUNK I think you will be better using Laravel Accessors/Mutators https://laravel.com/docs/11.x/eloquent-mutators#accessors-and-mutators and then add that as the select attribute in the field.

Basically define a public function fullContactName(): Attribute in your model and in the field, define attribute => fullContactName. Don't forget you need to add that attribute to model $appends. https://laravel.com/docs/11.x/eloquent-serialization#appending-values-to-json

I think adding the attribute to $appends it's what missing in your use case, and non of those overwrites would be needed.

Cheers

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GregaUNK
Comment options

Answer selected by GregaUNK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants