Skip to content

Commit

Permalink
Merge pull request #367 from MehediDracula/2.0
Browse files Browse the repository at this point in the history
Bind current object to the dynamic relations closure
  • Loading branch information
nWidart authored Aug 31, 2017
2 parents 33e556f + cb33f8c commit 62efe73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Modules/User/Entities/Sentinel/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ public function __call($method, $parameters)
#i: Relation method resolver
if (config()->has($config)) {
$function = config()->get($config);

return $function($this);
$bound = $function->bindTo($this);

return $bound();
}

#i: No relation found, return the call to parent (Eloquent) to handle it.
Expand Down
4 changes: 2 additions & 2 deletions config/asgard/user/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
| Add relations that will be dynamically added to the User entity
*/
'relations' => [
// 'extension' => function ($self) {
// return $self->belongsTo(UserExtension::class, 'user_id', 'id')->first();
// 'extension' => function () {
// return $this->belongsTo(UserExtension::class, 'user_id', 'id')->first();
// }
],
/*
Expand Down

0 comments on commit 62efe73

Please sign in to comment.