mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
Do not serialize company after migration
This commit is contained in:
parent
50f08362a3
commit
e63cf9c48f
@ -264,7 +264,7 @@ class Import implements ShouldQueue
|
|||||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||||
|
|
||||||
Mail::to($this->user->email, $this->user->name())
|
Mail::to($this->user->email, $this->user->name())
|
||||||
->send(new MigrationCompleted($this->company, implode("<br>",$check_data)));
|
->send(new MigrationCompleted($this->company->id, $this->company->db, implode("<br>",$check_data)));
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(\Exception $e) {
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
@ -715,6 +715,15 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
Client::reguard();
|
Client::reguard();
|
||||||
|
|
||||||
|
Client::with('contacts')->where('company_id', $this->company->id)->cursor()->each(function ($client){
|
||||||
|
|
||||||
|
$contact = $client->contacts->sortByDesc('is_primary')->first();
|
||||||
|
$contact->is_primary = true;
|
||||||
|
$contact->save();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/*Improve memory handling by setting everything to null when we have finished*/
|
/*Improve memory handling by setting everything to null when we have finished*/
|
||||||
$data = null;
|
$data = null;
|
||||||
$contact_repository = null;
|
$contact_repository = null;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@ -13,19 +14,23 @@ class MigrationCompleted extends Mailable
|
|||||||
{
|
{
|
||||||
// use Queueable, SerializesModels;
|
// use Queueable, SerializesModels;
|
||||||
|
|
||||||
public $company;
|
public $company_id;
|
||||||
|
|
||||||
|
public $db;
|
||||||
|
|
||||||
public $check_data;
|
public $check_data;
|
||||||
|
|
||||||
|
public $company;
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Company $company, $check_data = '')
|
public function __construct(int $company_id, string $db, $check_data = '')
|
||||||
{
|
{
|
||||||
$this->company = $company;
|
$this->company_id = $company_id;
|
||||||
$this->check_data = $check_data;
|
$this->check_data = $check_data;
|
||||||
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +40,10 @@ class MigrationCompleted extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
MultiDB::setDb($this->db);
|
||||||
|
$this->company = Company::find($this->company_id);
|
||||||
|
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user