mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
Relocate all 14 files from the catch-all app/Space namespace into proper locations: data providers to Support/Formatters, installation utilities to Services/Installation, PDF utils to Services/Pdf, module/update classes to Services/Module and Services/Update, SiteApi trait to Traits, and helpers to Support. Extract ~1,400 lines of business logic from 8 fat models (Invoice, Payment, Estimate, RecurringInvoice, Company, Customer, Expense, User) into 9 new service classes with constructor injection. Controllers now depend on services instead of calling static model methods. Shared item/tax creation logic consolidated into DocumentItemService.
60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Services\Backup\BackupConfigurationFactory;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Spatie\Backup\Tasks\Backup\BackupJobFactory;
|
|
|
|
class CreateBackupJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
protected $data;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($data = [])
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$config = BackupConfigurationFactory::make($this->data);
|
|
$backupJob = BackupJobFactory::createFromConfig($config);
|
|
if (! defined('SIGINT')) {
|
|
$backupJob->disableSignals();
|
|
}
|
|
|
|
if ($this->data['option'] === 'only-db') {
|
|
$backupJob->dontBackupFilesystem();
|
|
}
|
|
|
|
if ($this->data['option'] === 'only-files') {
|
|
$backupJob->dontBackupDatabases();
|
|
}
|
|
|
|
if (! empty($this->data['option'])) {
|
|
$prefix = str_replace('_', '-', $this->data['option']).'-';
|
|
|
|
$backupJob->setFilename($prefix.date('Y-m-d-H-i-s').'.zip');
|
|
}
|
|
|
|
$backupJob->run();
|
|
}
|
|
}
|