adrema/app/Nami/Api/FullMemberAction.php

35 lines
867 B
PHP
Raw Permalink Normal View History

2023-02-23 00:38:17 +01:00
<?php
namespace App\Nami\Api;
use App\Member\Data\FullMember;
use Illuminate\Support\Facades\Redis;
use Lorisleiva\Actions\Concerns\AsAction;
2023-05-03 22:36:02 +02:00
use Lorisleiva\Actions\Decorators\JobDecorator;
2023-02-23 00:38:17 +01:00
use Zoomyboy\LaravelNami\Api;
class FullMemberAction
{
use AsAction;
public function handle(Api $api, int $groupId, int $memberId, ?string $redisKey = null): FullMember
{
$fullMember = FullMember::from([
'member' => MemberAction::run($api, $groupId, $memberId),
'memberships' => MembershipsOfAction::run($api, $memberId),
'courses' => CoursesOfAction::run($api, $memberId),
]);
2023-05-03 21:26:27 +02:00
if ($redisKey) {
Redis::rpush($redisKey, $fullMember->toJson());
2023-02-23 00:38:17 +01:00
}
return $fullMember;
}
2023-05-03 22:36:02 +02:00
public function configureJob(JobDecorator $job): void
{
$job->setTries(8);
}
2023-02-23 00:38:17 +01:00
}