2018-10-24 05:50:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs\Company;
|
|
|
|
|
|
|
|
use App\Events\UserSignedUp;
|
2018-10-26 06:53:29 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-24 05:50:15 +02:00
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Models\Company;
|
|
|
|
|
|
|
|
class CreateCompany
|
|
|
|
{
|
2018-10-26 06:53:29 +02:00
|
|
|
use MakesHash;
|
2018-10-24 05:50:15 +02:00
|
|
|
use Dispatchable;
|
|
|
|
|
|
|
|
protected $request;
|
|
|
|
|
|
|
|
protected $account;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function __construct(Request $request, $account = false)
|
|
|
|
{
|
|
|
|
$this->request = $request;
|
|
|
|
$this->account = $account;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-11-27 08:24:26 +01:00
|
|
|
public function handle() : ?Company
|
2018-10-24 05:50:15 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
$company = new Company();
|
|
|
|
$company->name = $this->request->first_name . ' ' . $this->request->last_name;
|
|
|
|
$company->account_id = $this->account->id;
|
2018-10-26 06:53:29 +02:00
|
|
|
$company->company_key = $this->createHash();
|
2018-11-03 02:01:40 +01:00
|
|
|
$company->db = config('database.default');
|
2018-10-24 05:50:15 +02:00
|
|
|
$company->ip = $this->request->ip();
|
|
|
|
$company->save();
|
|
|
|
|
|
|
|
|
|
|
|
return $company;
|
|
|
|
}
|
|
|
|
}
|