Add member resync command

This commit is contained in:
philipp lang 2022-05-26 01:29:19 +02:00
parent cfdef13283
commit 65a8aa0ece
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use App\Actions\MemberPullAction;
use App\Setting\NamiSettings;
use Illuminate\Console\Command;
use Zoomyboy\LaravelNami\Member as NamiMember;
class MemberResyncCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'member:resync';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*
* @return int
*/
public function handle(NamiSettings $settings)
{
$api = $settings->login();
$api->search([])->each(
fn (NamiMember $member) => app(MemberPullAction::class)->api($api)->member($member->group_id, $member->id)->execute()
);
return 0;
}
}