42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Nami\Api;
|
|
|
|
use Illuminate\Bus\Batchable;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
class CompleteMemberToRedisJob implements ShouldQueue
|
|
{
|
|
use Batchable;
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public function __construct(
|
|
private Api $api,
|
|
private int $groupId,
|
|
private int $memberId,
|
|
) {
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
if ($this->batch()->cancelled()) {
|
|
return;
|
|
}
|
|
|
|
Redis::rpush('members', collect([
|
|
'member' => MemberAction::run($this->api, $this->groupId, $this->memberId),
|
|
'memberships' => MembershipsOfAction::run($this->api, $this->memberId),
|
|
'courses' => CoursesOfAction::run($this->api, $this->memberId),
|
|
])->toJson());
|
|
}
|
|
}
|