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

Bind current object to the dynamic relations closure #367

Merged
merged 3 commits into from
Aug 31, 2017
Merged

Bind current object to the dynamic relations closure #367

merged 3 commits into from
Aug 31, 2017

Conversation

MehediDracula
Copy link
Contributor

user can create dynamic relations without accepting the user object as a parameter. now $this in closure will refer to the User object.

'extension' => function () {
   return $this->belongsTo(UserExtension::class, 'user_id', 'id')->first();
}

@mikemand
Copy link
Contributor

This is awesome! Whenever I set up a relationship, I always forget to use $self instead of $this. 👍

@nWidart
Copy link
Member

nWidart commented Aug 30, 2017

Looks nice, but tests are failing.

@MehediDracula
Copy link
Contributor Author

Oops. my bad i used the shorthand way to binding the object scope and invoking it... it's a feature of PHP 7

@nWidart
Copy link
Member

nWidart commented Aug 31, 2017

Awesome! Thanks. 👍

@nWidart nWidart merged commit 62efe73 into AsgardCms:2.0 Aug 31, 2017
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.

3 participants