'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function isExpired(): bool { return $this->expires_at && $this->expires_at->isPast(); } public function refresh(): void { if (!$this->refresh_token) { throw new \RuntimeException('Nessun refresh token disponibile per ' . $this->email); } app(GoogleOAuthService::class)->refreshToken($this); } public function getValidAccessToken(): string { if ($this->isExpired() && $this->refresh_token) { $this->refresh(); } return $this->access_token; } }