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