mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
Multi-db support
This commit is contained in:
parent
42aef958fe
commit
03bb75674b
@ -34,6 +34,11 @@ class ImportData extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -45,6 +50,7 @@ class ImportData extends Job implements ShouldQueue
|
||||
$this->user = $user;
|
||||
$this->type = $type;
|
||||
$this->settings = $settings;
|
||||
$this->server = config('database.default');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,11 @@ class SendInvoiceEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $userId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -52,6 +57,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue
|
||||
$this->userId = $userId;
|
||||
$this->reminder = $reminder;
|
||||
$this->template = $template;
|
||||
$this->server = config('database.default');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,11 @@ class SendNotificationEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $notes;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
|
||||
@ -58,6 +63,7 @@ class SendNotificationEmail extends Job implements ShouldQueue
|
||||
$this->type = $type;
|
||||
$this->payment = $payment;
|
||||
$this->notes = $notes;
|
||||
$this->server = config('database.default');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,11 @@ class SendPaymentEmail extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $payment;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
|
||||
@ -28,6 +33,7 @@ class SendPaymentEmail extends Job implements ShouldQueue
|
||||
public function __construct($payment)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
$this->server = config('database.default');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,11 @@ class SendPushNotification extends Job implements ShouldQueue
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
|
||||
@ -35,6 +40,7 @@ class SendPushNotification extends Job implements ShouldQueue
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->type = $type;
|
||||
$this->server = config('database.default');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,6 +393,7 @@ class Utils
|
||||
'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
|
||||
'ip' => Request::getClientIp(),
|
||||
'count' => Session::get('error_count', 0),
|
||||
'is_console' => App::runningInConsole() ? 'yes' : 'no',
|
||||
];
|
||||
|
||||
if ($info) {
|
||||
|
@ -153,6 +153,7 @@ class InvoiceListener
|
||||
|
||||
public function jobFailed(JobExceptionOccurred $exception)
|
||||
{
|
||||
/*
|
||||
if ($errorEmail = env('ERROR_EMAIL')) {
|
||||
\Mail::raw(print_r($exception->data, true), function ($message) use ($errorEmail) {
|
||||
$message->to($errorEmail)
|
||||
@ -160,6 +161,7 @@ class InvoiceListener
|
||||
->subject('Job failed');
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
Utils::logError($exception->exception);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ use Request;
|
||||
use URL;
|
||||
use Utils;
|
||||
use Validator;
|
||||
use Queue;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
|
||||
/**
|
||||
* Class AppServiceProvider.
|
||||
@ -21,6 +23,14 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Queue::before(function (JobProcessing $event) {
|
||||
$body = $event->job->getRawBody();
|
||||
preg_match('/db-ninja-[\d+]/', $body, $matches);
|
||||
if (count($matches)) {
|
||||
config(['database.default' => $matches[0]]);
|
||||
}
|
||||
});
|
||||
|
||||
Form::macro('image_data', function ($image, $contents = false) {
|
||||
if (! $contents) {
|
||||
$contents = file_get_contents($image);
|
||||
|
@ -36,6 +36,7 @@ return [
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'connection' => env('QUEUE_DATABASE', 'mysql'),
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
@ -86,7 +87,8 @@ return [
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'database' => 'mysql', 'table' => 'failed_jobs',
|
||||
'database' => env('QUEUE_DATABASE', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user