I have created a TokenRepository
with 3 methods.
Those methods create an entry to same a table but each method have different fields. Is this good pattern or should I use an interface and 3 implementations or merge 3 methods into 1 method?
For example:
class TokenRepository
{
public function createTokenDigitalOcean(User $user, $name, $accessToken, $refreshToken = null)
{
return $user->tokens()->create([
'name' => $name,
'provider' => 'digital_ocean',
'access_token' => $accessToken,
'refresh_token' => $refreshToken,
]);
}
public function createTokenLinode(User $user, $name, $key)
{
return $user->tokens()->create([
'name' => $name,
'provider' => 'linode',
'linode_key' => $key,
]);
}
public function createTokenAws(User $user, $name, $key, $secret)
{
return $user->tokens()->create([
'name' => $name,
'provider' => 'aws',
'aws_key' => $key,
'aws_secret' => $secret,
]);
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2futre9
via IFTTT
Aucun commentaire:
Enregistrer un commentaire