1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Jobs/Company/CreateCompany.php
David Bomba c72e1f0139
Client Creation (#2533)
* Working on Oauth

* splitting out JS files

* Working on oAuth

*  working on oAuth

* minor fixes

* create client

* create client

* create client

* Working on adding a client
2018-12-02 21:42:06 +11:00

52 lines
1.0 KiB
PHP

<?php
namespace App\Jobs\Company;
use App\Events\UserSignedUp;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use App\Models\Company;
class CreateCompany
{
use MakesHash;
use Dispatchable;
protected $request;
protected $account;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $request, $account = false)
{
$this->request = $request;
$this->account = $account;
}
/**
* Execute the job.
*
* @return void
*/
public function handle() : ?Company
{
$company = new Company();
$company->name = $this->request['first_name'] . ' ' . $this->request['last_name'];
$company->account_id = $this->account->id;
$company->company_key = $this->createHash();
$company->db = config('database.default');
$company->ip = request()->ip();
$company->save();
return $company;
}
}