Skip to content

Commit

Permalink
New method instead of all the config() calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewSH committed Mar 23, 2018
1 parent 40bb467 commit 0586b8b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TokenRepository
*/
public function create($attributes)
{
return config('passport.token.model', Laravel\Passport\Token::class)::create($attributes);
return $this->newTokenInstance()::create($attributes);
}

/**
Expand All @@ -26,7 +26,7 @@ public function create($attributes)
*/
public function find($id)
{
return config('passport.token.model', Laravel\Passport\Token::class)::find($id);
return $this->newTokenInstance()::find($id);
}

/**
Expand All @@ -38,7 +38,7 @@ public function find($id)
*/
public function findForUser($id, $userId)
{
return config('passport.token.model', Laravel\Passport\Token::class)::where('id', $id)->where('user_id', $userId)->first();
return $this->newTokenInstance()::where('id', $id)->where('user_id', $userId)->first();
}

/**
Expand All @@ -49,7 +49,7 @@ public function findForUser($id, $userId)
*/
public function forUser($userId)
{
return config('passport.token.model', Laravel\Passport\Token::class)::where('user_id', $userId)->get();
return $this->newTokenInstance()::where('user_id', $userId)->get();
}

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public function save(Token $token)
*/
public function revokeAccessToken($id)
{
return config('passport.token.model', Laravel\Passport\Token::class)::where('id', $id)->update(['revoked' => true]);
return $this->newTokenInstance()::where('id', $id)->update(['revoked' => true]);
}

/**
Expand Down Expand Up @@ -122,4 +122,9 @@ public function findValidToken($user, $client)
->latest('expires_at')
->first();
}

public function newTokenInstance()
{
return config('passport.token.model', Laravel\Passport\Token::class);
}
}

0 comments on commit 0586b8b

Please sign in to comment.