2022-01-03 10:33:48 +01:00
|
|
|
<?php
|
2020-04-12 00:26:44 +02:00
|
|
|
|
|
|
|
namespace App\Initialize;
|
|
|
|
|
2023-02-06 00:24:57 +01:00
|
|
|
use App\Actions\PullMemberAction;
|
2022-09-02 00:45:39 +02:00
|
|
|
use DB;
|
2022-02-12 16:16:56 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
2021-11-17 22:32:52 +01:00
|
|
|
use Zoomyboy\LaravelNami\Member as NamiMember;
|
2021-04-10 01:39:39 +02:00
|
|
|
|
2022-03-11 20:19:17 +01:00
|
|
|
class InitializeMembers
|
|
|
|
{
|
2022-02-12 16:16:56 +01:00
|
|
|
private Api $api;
|
2022-01-03 10:33:48 +01:00
|
|
|
|
2022-03-11 20:19:17 +01:00
|
|
|
public function __construct(Api $api)
|
|
|
|
{
|
2020-04-12 00:26:44 +02:00
|
|
|
$this->api = $api;
|
|
|
|
}
|
|
|
|
|
2022-02-12 16:16:56 +01:00
|
|
|
public function handle(): void
|
|
|
|
{
|
2020-04-12 00:26:44 +02:00
|
|
|
$allMembers = collect([]);
|
|
|
|
|
2022-04-29 00:50:41 +02:00
|
|
|
$this->api->search([])->each(
|
2023-02-06 00:24:57 +01:00
|
|
|
fn (NamiMember $member) => app(PullMemberAction::class)->api($this->api)->member($member->group_id, $member->id)->execute()
|
2022-04-29 00:50:41 +02:00
|
|
|
);
|
2022-01-03 10:33:48 +01:00
|
|
|
}
|
2022-09-02 00:45:39 +02:00
|
|
|
|
|
|
|
public function restore(): void
|
|
|
|
{
|
|
|
|
DB::table('payments')->delete();
|
|
|
|
DB::table('course_members')->delete();
|
|
|
|
DB::table('memberships')->delete();
|
|
|
|
DB::table('members')->delete();
|
|
|
|
}
|
2020-04-12 00:26:44 +02:00
|
|
|
}
|