Commit 62efe73a authored by Nicolas Widart's avatar Nicolas Widart Committed by GitHub

Merge pull request #367 from MehediDracula/2.0

Bind current object to the dynamic relations closure
parents 33e556f1 cb33f8c4
...@@ -113,8 +113,9 @@ class User extends EloquentUser implements UserInterface, AuthenticatableContrac ...@@ -113,8 +113,9 @@ class User extends EloquentUser implements UserInterface, AuthenticatableContrac
#i: Relation method resolver #i: Relation method resolver
if (config()->has($config)) { if (config()->has($config)) {
$function = config()->get($config); $function = config()->get($config);
$bound = $function->bindTo($this);
return $function($this);
return $bound();
} }
#i: No relation found, return the call to parent (Eloquent) to handle it. #i: No relation found, return the call to parent (Eloquent) to handle it.
......
...@@ -85,8 +85,8 @@ return [ ...@@ -85,8 +85,8 @@ return [
| Add relations that will be dynamically added to the User entity | Add relations that will be dynamically added to the User entity
*/ */
'relations' => [ 'relations' => [
// 'extension' => function ($self) { // 'extension' => function () {
// return $self->belongsTo(UserExtension::class, 'user_id', 'id')->first(); // return $this->belongsTo(UserExtension::class, 'user_id', 'id')->first();
// } // }
], ],
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment