Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
imrealashu opened this issue Sep 12, 2015 · 1 comment
Closed

Comments

@imrealashu
Copy link

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
Copy link
Owner

nqxcode commented Sep 12, 2015

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",
                ];
        }

@nqxcode nqxcode closed this as completed Sep 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants