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

Allow to() & from() with Model #110

Closed
Gummibeer opened this issue Apr 26, 2016 · 3 comments
Closed

Allow to() & from() with Model #110

Gummibeer opened this issue Apr 26, 2016 · 3 comments

Comments

@Gummibeer
Copy link
Collaborator

Allow to put in an EloquentModel in the to() and from() methods.

protected function setEntityAction($from, $property)
    {
        // Check if has the entity as parameter
        // it should be the firstOne
        if ($this->hasEntity($from)) {
            $this->isString($from[0]);
            $this->isNumeric($from[1]);

            $this->setBuilderData("{$property}_type", $from[0]);
            $this->setBuilderData("{$property}_id", $from[1]);
        } elseif($from[0] instanceof Model) {
            $this->setBuilderData("{$property}_type", get_class($from[0]));
            $this->setBuilderData("{$property}_id", $from[0]->getKey());
        } else {
            $this->isNumeric($from[0]);
            $this->setBuilderData("{$property}_id", $from[0]);
        }
    }
@Gummibeer Gummibeer self-assigned this Apr 26, 2016
Gummibeer added a commit that referenced this issue Apr 26, 2016
Gummibeer added a commit that referenced this issue Apr 26, 2016
@Gummibeer
Copy link
Collaborator Author

PR #111 has been merged - done & closed

Gummibeer added a commit that referenced this issue Apr 27, 2016
update `get_class()` to `getMorphClass()`
@Gummibeer
Copy link
Collaborator Author

adding a small improvement getMorphClass()

@Gummibeer Gummibeer reopened this Apr 27, 2016
Gummibeer added a commit that referenced this issue Apr 27, 2016
@Gummibeer
Copy link
Collaborator Author

PR #112 has been merged - done & closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant