93 lines
2.6 KiB
PHP
93 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Company;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\Company\Company;
|
|
|
|
class Details
|
|
{
|
|
use HasFactory;
|
|
public $details;
|
|
private $company;
|
|
public function __construct(Company $company)
|
|
{
|
|
$this->company = $company;
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
if (!$this->company->details)
|
|
{
|
|
if ($this->company->type == CompanyType::SelfEmployer)
|
|
{
|
|
$this->company->details = $this->emptyForSelfEmp();
|
|
$this->company->save();
|
|
}
|
|
;
|
|
if ($this->company->type == CompanyType::SoleProperty)
|
|
{
|
|
$this->company->details = $this->emptyForSelfEmp();
|
|
$this->company->save();
|
|
}
|
|
;
|
|
if ($this->company->type == CompanyType::Agency)
|
|
{
|
|
$this->company->details = $this->emptyForAgency();
|
|
$this->company->save();
|
|
}
|
|
}
|
|
return $this->details = $this->company->details;
|
|
}
|
|
|
|
private function emptyForSelfEmp()
|
|
{
|
|
$data = [
|
|
'user' => [
|
|
'firstName' => '',
|
|
'secondName' => '',
|
|
'email' => $this->company->email,
|
|
'phone' => ''
|
|
],
|
|
'details' => [
|
|
'inn' => $this->company->inn,
|
|
'snils' => '',
|
|
'bank' => [
|
|
'name' => '',
|
|
'bik' => '',
|
|
'cur' => '',
|
|
'pers' => ''
|
|
],
|
|
'address' => $this->company->address,
|
|
'legal_address' => $this->company->legal_address
|
|
]
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
private function emptyForAgency()
|
|
{
|
|
$data = [
|
|
'name' => $this->company->name,
|
|
'fullName' => '',
|
|
'email' => $this->company->email,
|
|
'details' => [
|
|
'inn' => $this->company->inn,
|
|
'kpp' => '',
|
|
'ogrn' => '',
|
|
'bank' => [
|
|
'name' => '',
|
|
'bik' => '',
|
|
'cur' => '',
|
|
'pers' => ''
|
|
],
|
|
'address' => $this->company->address,
|
|
'legal_address' => $this->company->legal_address,
|
|
'post_address' => ''
|
|
]
|
|
];
|
|
return $data;
|
|
}
|
|
}
|