fadion / Bouncy

Map Elasticsearch results to Eloquent models
MIT License
71 stars 26 forks source link

Customizing Document Fields #7

Closed stevepop closed 9 years ago

stevepop commented 9 years ago

Hi, I tried creating the $documentFields property in my model but was getting an error in my IDE, "expression is not allowed as field default value". I even copied the array in the documentation thinking that I probably have a typo somewhere but got the same error.

I needed to do this as I need to have a custom field for "full_name" which is a concatenation of first_name and last_name but I don't want to have to create this in my database.

Can you reproduce this error? what seems to be the issue?

Thanks.

fadion commented 9 years ago

The IDE is right! I overlooked the fact that an object property can't be accessed inside another object property. This doesn't work:

$documentFields = [
   'title' => $this->title // accessing another object property
];

I'll make 'documentFields' a method and update the documentation in a few minutes.

stevepop commented 9 years ago

Hi Fadion,

Nice work. Glad I was able to spot that. That's to tell you I am actively using Bouncy for my projects :)

Thanks for the good work.

Regards,

Steve

On Tue, May 5, 2015 at 8:37 PM, Fadion Dashi notifications@github.com wrote:

The IDE is right! I overlooked the fact that an object property can't be accessed inside another object property. This doesn't work:

$documentFields = [ 'title' => $this->title // accessing another object property];

I'll make 'documentFields' a method and update the documentation in a few minutes.

— Reply to this email directly or view it on GitHub https://github.com/fadion/Bouncy/issues/7#issuecomment-99198588.

Steve O. Popoola Email: stevepop@gmail.com LinkedIn: http://uk.linkedin.com/in/stevepop Twitter ID: http://www.twitter.com/stpopoola

fadion commented 9 years ago

I'm glad to hear that. Feel free to suggest any enhancement or feature.