Wanna build an instantsearch page [Laravel]

Hey guys,

I am trying to set up an instantsearch page with laravel where you can search after articles. These articles have a relation articlevotes and categories. How should I get my votes? Through relationship? Or should I save the votes to the articles table? What is the way to go in this situation with algolia?

Best regards

1 Like

Hey @NastyPasty :wave:

Thanks for using Algolia! You should overwrite the method toSearchableArray inside your Article Model.

Inside the toSearchableArray you should add to the base array a new property called votes_count for example.

There is a good article about this: algolia.com/doc/api-client/laravel/relationships.

Make sure you re-import your models after the modification.


1 Like