Refactor + package updates + improve local backups
This commit is contained in:
41
app/Http/Livewire/Project/Database/BackupEdit.php
Normal file
41
app/Http/Livewire/Project/Database/BackupEdit.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Database;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class BackupEdit extends Component
|
||||
{
|
||||
public $backup;
|
||||
|
||||
protected $rules = [
|
||||
'backup.enabled' => 'required|boolean',
|
||||
'backup.frequency' => 'required|string',
|
||||
'backup.number_of_backups_locally' => 'required|integer|min:1',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'backup.enabled' => 'Enabled',
|
||||
'backup.frequency' => 'Frequency',
|
||||
'backup.number_of_backups_locally' => 'Number of Backups Locally',
|
||||
];
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
$this->backup->save();
|
||||
$this->backup->refresh();
|
||||
$this->emit('success', 'Backup updated successfully');
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$isValid = validate_cron_expression($this->backup->frequency);
|
||||
if (!$isValid) {
|
||||
$this->emit('error', 'Invalid Cron / Human expression');
|
||||
return;
|
||||
}
|
||||
$this->validate();
|
||||
$this->backup->save();
|
||||
$this->backup->refresh();
|
||||
$this->emit('success', 'Backup updated successfully');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user