12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Modules\Mini\Services;
- use App\Base\BaseService;
- use App\Models\User\User;
- use App\Models\User\UserCompany;
- use Illuminate\Support\Arr;
- class CompanyService extends BaseService
- {
- public function company(User $user, $params)
- {
- if ($user->company) {
- // if ($user->company->status == UserCompany::STATUS_INIT) {
- // throw new ClientException("已经提交过资料了");
- // } else {
- $user->company->name = $params['name'];
- $user->company->tax_no = $params['tax_no'];
- $user->company->status = 1;
- $user->company->tel = Arr::get($params, "tel");
- $user->company->department = Arr::get($params, "department");
- $user->company->linkman = Arr::get($params, "linkman");
- $user->company->address = Arr::get($params, "address");
- $user->company->save();
- // }
- return $user->company;
- } else {
- $company = new UserCompany();
- $company->name = $params['name'];
- $company->user_id = $user->id;
- $company->tax_no = $params['tax_no'];
- $company->status = 1;
- $company->tel = Arr::get($params, "tel");
- $company->department = Arr::get($params, "department");
- $company->linkman = Arr::get($params, "linkman");
- $company->address = Arr::get($params, "address");
- $company->save();
- return $company;
- }
- }
- }
|