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

Fixes relation create return type #320

Merged
merged 2 commits into from
Oct 7, 2019
Merged

Fixes relation create return type #320

merged 2 commits into from
Oct 7, 2019

Conversation

canvural
Copy link
Collaborator

@canvural canvural commented Oct 6, 2019

This one fixes the return type of create method on relations. For example $user->accounts()->create() should return newly created Account model.

The code makes a couple of assumptions. First of all, the model needs to define the property in the docblock of the class. laravel-ide-helper can write PHP docs for the models automatically. If a phpdoc does not exist for the given property, MixedType return type is used to avoid errors.

Secondly, I followed the convention from laravel-ide-helper so typehint should be either Collection|ModelName[] or ModelName. If it can't match it, MixedType is returned again.

@szepeviktor
Copy link
Collaborator

Thank you.

@szepeviktor
Copy link
Collaborator

Is it related to #208 ?

@canvural
Copy link
Collaborator Author

canvural commented Oct 6, 2019

@szepeviktor No, it's not related to that. This is just for calling create on the relation.

@nunomaduro
Copy link
Collaborator

@canvural Can you update this pull request?

@canvural
Copy link
Collaborator Author

canvural commented Oct 7, 2019

@nunomaduro Done 👍

@nunomaduro nunomaduro merged commit 2d4fc61 into larastan:master Oct 7, 2019
@nunomaduro
Copy link
Collaborator

nunomaduro commented Oct 7, 2019

Fell free to release a new version once you think it's appropriated. Don't forget, we should always discuss about major versions.

That being said, the next version should be v0.4.2. Check the RELEASE.md for more details.

@nunomaduro
Copy link
Collaborator

cc @canvural

@canvural canvural deleted the fix-relation-create-return-type branch October 7, 2019 11:46
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

Successfully merging this pull request may close these issues.

None yet

3 participants