nqxcode / laravel-lucene-search

Laravel 4.2, 5.* package for full-text search over Eloquent models based on ZF2 Lucene.
73 stars 28 forks source link

Add feature to change value of a Foreign key using Eloquent model. #16

Closed imrealashu closed 9 years ago

imrealashu commented 9 years ago

For example:

table1 id = 1 (PK) value = 'Something'

table2 id = 2 table1_id = 1 another_field='something else'

After Indexing table2 result will be

id=2 table1_id='something' another_field='something else'

nqxcode commented 9 years ago

In this example arise problem: what field from table1 to add to index if table1 have other fields, besides "value" field?

Therefore for all related fields use indexing for "dynamic fields" (see in readme). For example:

  1. In config.php for model of table2 add following option:
        'optional_attributes' => true
  1. Add this accessor in model of table2
        public function getOptionalAttributesAttribute()
        {
                return [
                        'table1_id' => "something",
                ];
        }