diff --git a/app/Events/Common/CompanyCreated.php b/app/Events/Common/CompanyCreated.php index dc0a6f4fc..612cba4ee 100644 --- a/app/Events/Common/CompanyCreated.php +++ b/app/Events/Common/CompanyCreated.php @@ -8,13 +8,16 @@ class CompanyCreated extends Event { public $company; + public $request; + /** * Create a new event instance. * * @param $company */ - public function __construct($company) + public function __construct($company, $request = null) { $this->company = $company; + $this->request = $request; } } diff --git a/app/Jobs/Common/CreateCompany.php b/app/Jobs/Common/CreateCompany.php index 17807df7c..6991d641f 100644 --- a/app/Jobs/Common/CreateCompany.php +++ b/app/Jobs/Common/CreateCompany.php @@ -29,12 +29,12 @@ class CreateCompany extends Job implements HasOwner, HasSource, ShouldCreate $this->updateSettings(); }); - event(new CompanyCreated($this->model)); - - if (!empty($current_company_id)) { + if (! empty($current_company_id)) { company($current_company_id)->makeCurrent(); } + event(new CompanyCreated($this->model, $this->request)); + return $this->model; }