'integer', 'certificate' => 'encrypted', 'pk' => 'encrypted', 'ca' => 'encrypted', 'expires_at' => 'datetime', ]; public function site(): BelongsTo { return $this->belongsTo(Site::class); } public function getCertsDirectoryPathAttribute(): ?string { if ($this->type == 'letsencrypt') { return '/etc/letsencrypt/live/'.$this->site->domain; } if ($this->type == 'custom') { return '/etc/ssl/'.$this->site->domain; } return ''; } public function getCertificatePathAttribute(): ?string { if ($this->type == 'letsencrypt') { return $this->certificate; } if ($this->type == 'custom') { return $this->certs_directory_path.'/cert.pem'; } return ''; } public function getPkPathAttribute(): ?string { if ($this->type == 'letsencrypt') { return $this->pk; } if ($this->type == 'custom') { return $this->certs_directory_path.'/privkey.pem'; } return ''; } public function getCaPathAttribute(): ?string { if ($this->type == 'letsencrypt') { return $this->ca; } if ($this->type == 'custom') { return $this->certs_directory_path.'/fullchain.pem'; } return ''; } public function deploy(): void { dispatch(new Deploy($this))->onConnection('ssh'); } public function remove(): void { $this->status = SslStatus::DELETING; $this->save(); dispatch(new Remove($this))->onConnection('ssh'); } public function validateSetup(string $result): bool { if (! Str::contains($result, 'Successfully received certificate')) { return false; } if ($this->type == 'letsencrypt') { $this->certificate = $this->certs_directory_path.'/fullchain.pem'; $this->pk = $this->certs_directory_path.'/privkey.pem'; $this->save(); } return true; } }