1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Jobs/Company/CreateCompany.php

66 lines
1.4 KiB
PHP
Raw Normal View History

2018-10-24 05:50:15 +02:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
2018-10-24 05:50:15 +02:00
namespace App\Jobs\Company;
2019-02-17 12:07:58 +01:00
use App\DataMapper\CompanySettings;
2018-10-24 05:50:15 +02:00
use App\Events\UserSignedUp;
2019-02-17 12:07:58 +01:00
use App\Models\Company;
use App\Utils\Traits\MakesHash;
2018-10-24 05:50:15 +02:00
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
class CreateCompany
{
use MakesHash;
2018-10-24 05:50:15 +02:00
use Dispatchable;
protected $request;
protected $account;
/**
* Create a new job instance.
*
* @return void
*/
2019-06-17 01:58:33 +02:00
public function __construct(array $request, $account)
2018-10-24 05:50:15 +02:00
{
2019-06-17 01:58:33 +02:00
2018-10-24 05:50:15 +02:00
$this->request = $request;
2019-06-17 01:58:33 +02:00
2018-10-24 05:50:15 +02:00
$this->account = $account;
2019-06-17 01:58:33 +02:00
2018-10-24 05:50:15 +02:00
}
/**
* Execute the job.
*
* @return void
*/
public function handle() : ?Company
2018-10-24 05:50:15 +02:00
{
$company = new Company();
$company->name = isset($this->request['name']) ? $this->request['name'] : $this->request['first_name'] . ' ' . $this->request['last_name'];
2018-10-24 05:50:15 +02:00
$company->account_id = $this->account->id;
$company->company_key = $this->createHash();
$company->ip = request()->ip();
2019-09-19 07:50:05 +02:00
$company->settings = CompanySettings::defaults();
$company->db = config('database.default');
2018-10-24 05:50:15 +02:00
$company->save();
return $company;
}
}