46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\GoogleService;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Crypt;
|
|
|
|
class GoogleOAuthConnection extends Model
|
|
{
|
|
protected $fillable = [
|
|
'service',
|
|
'client_id',
|
|
'client_secret',
|
|
'refresh_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'service' => GoogleService::class,
|
|
];
|
|
}
|
|
|
|
public function getClientSecretAttribute(?string $value): ?string
|
|
{
|
|
return $value ? Crypt::decryptString($value) : null;
|
|
}
|
|
|
|
public function setClientSecretAttribute(?string $value): void
|
|
{
|
|
$this->attributes['client_secret'] = $value ? Crypt::encryptString($value) : null;
|
|
}
|
|
|
|
public function getRefreshTokenAttribute(?string $value): ?string
|
|
{
|
|
return $value ? Crypt::decryptString($value) : null;
|
|
}
|
|
|
|
public function setRefreshTokenAttribute(?string $value): void
|
|
{
|
|
$this->attributes['refresh_token'] = $value ? Crypt::encryptString($value) : null;
|
|
}
|
|
} |