mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
build version 400
This commit is contained in:
61
app/Jobs/CreateBackupJob.php
Normal file
61
app/Jobs/CreateBackupJob.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Jobs;
|
||||
|
||||
use Crater\Models\FileDisk;
|
||||
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, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data = '')
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$fileDisk = FileDisk::find($this->data['file_disk_id']);
|
||||
$fileDisk->setConfig();
|
||||
|
||||
$prefix = env('DYNAMIC_DISK_PREFIX', 'temp_');
|
||||
|
||||
config(['backup.backup.destination.disks' => [$prefix . $fileDisk->driver]]);
|
||||
|
||||
$backupJob = BackupJobFactory::createFromArray(config('backup'));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
40
app/Jobs/GenerateEstimatePdfJob.php
Normal file
40
app/Jobs/GenerateEstimatePdfJob.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class GenerateEstimatePdfJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $estimate;
|
||||
public $deleteExistingFile;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($estimate, $deleteExistingFile = false)
|
||||
{
|
||||
$this->estimate = $estimate;
|
||||
$this->deleteExistingFile = $deleteExistingFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->estimate->generatePDF('estimate', $this->estimate->estimate_number, $this->deleteExistingFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
40
app/Jobs/GenerateInvoicePdfJob.php
Normal file
40
app/Jobs/GenerateInvoicePdfJob.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class GenerateInvoicePdfJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
public $deleteExistingFile;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($invoice, $deleteExistingFile = false)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->deleteExistingFile = $deleteExistingFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->invoice->generatePDF('invoice', $this->invoice->invoice_number, $this->deleteExistingFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
40
app/Jobs/GeneratePaymentPdfJob.php
Normal file
40
app/Jobs/GeneratePaymentPdfJob.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class GeneratePaymentPdfJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $payment;
|
||||
public $deleteExistingFile;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($payment, $deleteExistingFile = false)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
$this->deleteExistingFile = $deleteExistingFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->payment->generatePDF('payment', $this->payment->payment_number, $this->deleteExistingFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user