2021-06-13 11:33:50 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Member;
|
|
|
|
|
2022-01-02 12:32:57 +01:00
|
|
|
use App\Confession;
|
2022-02-12 15:33:16 +01:00
|
|
|
use App\User;
|
2021-06-13 11:33:50 +02:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Zoomyboy\LaravelNami\Nami;
|
|
|
|
|
|
|
|
class UpdateJob implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
2022-02-12 15:33:16 +01:00
|
|
|
public int $memberId;
|
|
|
|
public Member $member;
|
2021-06-13 11:33:50 +02:00
|
|
|
|
2022-02-19 18:06:07 +01:00
|
|
|
public function __construct(Member $member)
|
2021-06-13 11:33:50 +02:00
|
|
|
{
|
|
|
|
$this->memberId = $member->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->member = Member::find($this->memberId);
|
|
|
|
|
2021-06-21 23:50:09 +02:00
|
|
|
if (!$this->member->hasNami) {
|
2022-01-02 12:32:57 +01:00
|
|
|
return;
|
2021-06-21 23:50:09 +02:00
|
|
|
}
|
|
|
|
|
2022-02-19 18:06:07 +01:00
|
|
|
$response = $this->service->login()->putMember([
|
2021-06-13 11:33:50 +02:00
|
|
|
'firstname' => $this->member->firstname,
|
|
|
|
'lastname' => $this->member->lastname,
|
|
|
|
'joined_at' => $this->member->joined_at,
|
|
|
|
'birthday' => $this->member->birthday,
|
|
|
|
'send_newspaper' => $this->member->send_newspaper,
|
|
|
|
'address' => $this->member->address,
|
|
|
|
'zip' => $this->member->zip,
|
|
|
|
'location' => $this->member->location,
|
|
|
|
'nickname' => $this->member->nickname,
|
|
|
|
'other_country' => $this->member->other_country,
|
|
|
|
'further_address' => $this->member->further_address,
|
|
|
|
'main_phone' => $this->member->main_phone,
|
|
|
|
'mobile_phone' => $this->member->mobile_phone,
|
|
|
|
'work_phone' => $this->member->work_phone,
|
|
|
|
'fax' => $this->member->fax,
|
|
|
|
'email' => $this->member->email,
|
|
|
|
'email_parents' => $this->member->email_parents,
|
2021-06-21 23:50:09 +02:00
|
|
|
'gender_id' => optional($this->member->gender)->nami_id,
|
|
|
|
'confession_id' => $this->member->confession ? $this->member->confession->nami_id : Confession::firstWhere('is_null', true)->id,
|
2021-06-13 11:33:50 +02:00
|
|
|
'region_id' => optional($this->member->region)->nami_id,
|
|
|
|
'country_id' => $this->member->country->nami_id,
|
2021-07-04 12:09:30 +02:00
|
|
|
'fee_id' => $this->member->getNamiFeeId(),
|
2021-06-13 11:33:50 +02:00
|
|
|
'nationality_id' => $this->member->nationality->nami_id,
|
|
|
|
'id' => $this->member->nami_id,
|
|
|
|
'group_id' => $this->member->group->nami_id,
|
2021-06-21 23:50:09 +02:00
|
|
|
'version' => $this->member->version,
|
2021-06-13 11:33:50 +02:00
|
|
|
]);
|
2021-06-21 23:50:09 +02:00
|
|
|
Member::withoutEvents(function() use ($response) {
|
|
|
|
$this->member->update(['version' => $response['version']]);
|
|
|
|
});
|
2021-06-13 11:33:50 +02:00
|
|
|
}
|
|
|
|
}
|