chore: improve code quality suggested by code rabbit
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneDragonfly;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Validate;
|
||||
@@ -52,7 +53,7 @@ class General extends Component
|
||||
#[Validate(['nullable', 'boolean'])]
|
||||
public bool $isLogDrainEnabled = false;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
#[Validate(['nullable', 'boolean'])]
|
||||
public bool $enable_ssl = false;
|
||||
@@ -72,9 +73,7 @@ class General extends Component
|
||||
$this->syncData();
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -205,10 +204,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneKeydb;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Validate;
|
||||
@@ -55,7 +56,7 @@ class General extends Component
|
||||
#[Validate(['nullable', 'boolean'])]
|
||||
public bool $isLogDrainEnabled = false;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
#[Validate(['boolean'])]
|
||||
public bool $enable_ssl = false;
|
||||
@@ -75,9 +76,7 @@ class General extends Component
|
||||
$this->syncData();
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -210,10 +209,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneMariadb;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -23,7 +24,7 @@ class General extends Component
|
||||
|
||||
public ?string $db_url_public = null;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
protected $rules = [
|
||||
'database.name' => 'required',
|
||||
@@ -64,9 +65,7 @@ class General extends Component
|
||||
$this->db_url_public = $this->database->external_db_url;
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -155,10 +154,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneMongodb;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -23,7 +24,7 @@ class General extends Component
|
||||
|
||||
public ?string $db_url_public = null;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
protected $rules = [
|
||||
'database.name' => 'required',
|
||||
@@ -64,9 +65,7 @@ class General extends Component
|
||||
$this->db_url_public = $this->database->external_db_url;
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -159,10 +158,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneMysql;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -23,7 +24,7 @@ class General extends Component
|
||||
|
||||
public ?string $db_url_public = null;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
protected $rules = [
|
||||
'database.name' => 'required',
|
||||
@@ -66,9 +67,7 @@ class General extends Component
|
||||
$this->db_url_public = $this->database->external_db_url;
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -158,10 +157,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -25,7 +26,7 @@ class General extends Component
|
||||
|
||||
public ?string $db_url_public = null;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
public function getListeners()
|
||||
{
|
||||
@@ -81,9 +82,7 @@ class General extends Component
|
||||
$this->db_url_public = $this->database->external_db_url;
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -122,10 +121,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;
|
||||
use App\Models\Server;
|
||||
use App\Models\SslCertificate;
|
||||
use App\Models\StandaloneRedis;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -32,7 +33,7 @@ class General extends Component
|
||||
|
||||
public ?string $db_url_public = null;
|
||||
|
||||
public $certificateValidUntil = null;
|
||||
public ?Carbon $certificateValidUntil = null;
|
||||
|
||||
protected $rules = [
|
||||
'database.name' => 'required',
|
||||
@@ -67,9 +68,7 @@ class General extends Component
|
||||
{
|
||||
$this->server = data_get($this->database, 'destination.server');
|
||||
$this->refreshView();
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if ($existingCert) {
|
||||
$this->certificateValidUntil = $existingCert->valid_until;
|
||||
@@ -163,10 +162,7 @@ class General extends Component
|
||||
public function regenerateSslCertificate()
|
||||
{
|
||||
try {
|
||||
$existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())
|
||||
->where('resource_id', $this->database->id)
|
||||
->where('server_id', $this->server->id)
|
||||
->first();
|
||||
$existingCert = $this->database->sslCertificates()->first();
|
||||
|
||||
if (! $existingCert) {
|
||||
$this->dispatch('error', 'No existing SSL certificate found for this database.');
|
||||
|
||||
Reference in New Issue
Block a user