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

gii model generator - ignore behavior properties #372

Open
tarranjones opened this issue Jun 20, 2018 · 1 comment
Open

gii model generator - ignore behavior properties #372

tarranjones opened this issue Jun 20, 2018 · 1 comment

Comments

@tarranjones
Copy link

you cannot have a column called owner_id if you have any behavior attached to your base model

I think it would make more sense to ignore behaviors when creating relation names as some relation names will be illformed.

What steps will reproduce the problem?

run gii model generator with any behavior already attached to the basemodel and have a column name which relation name will share the name of any public behavior property.

Any behavior which inherits from the attributebehavior (timestamp,blamable) will cause the
value_id relation name to be getValue0()

the attributesbehavior will cause the
order_id relation name to be getOrder0()

and ALL behaviors will cause

owner_id relation name to be getOwner0()

A solution would be to

protected function generateRelationName($relations, $table, $key, $multiple)
... 
//replace
while ($baseModel->hasProperty(lcfirst($name))) {
//with
while ($baseModel->hasProperty(lcfirst($name), true, false)) {

`

example 

### What's expected?

`public function getOwner()`

### What do you get instead?

`public function getOwner0()`

### Additional info
@samdark
Copy link
Member

samdark commented Jun 20, 2018

Won't that make behaviors non-functional?

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