68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\FreeCompanyRankedUser;
|
|
use App\Services\LodestoneApiService;
|
|
use App\Services\LodestoneCacheService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class HelixRankCheckCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'chaosbot:cron';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Runs Helix crons';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle(LodestoneCacheService $cacheService, LodestoneApiService $apiService)
|
|
{
|
|
$fcInfo = $cacheService->getFreeCompanyById('9231394073691143535', $apiService);
|
|
$members = $fcInfo->content['FreeCompanyMembers'];
|
|
foreach ($members as $member) {
|
|
$rankedUser = FreeCompanyRankedUser::where('lodestoneId', $member['ID'])->first();
|
|
|
|
if ($rankedUser === null)
|
|
{
|
|
$rankedUser = new FreeCompanyRankedUser;
|
|
$rankedUser->lodestoneId = $member['ID'];
|
|
}
|
|
|
|
$rankedUser->displayName = $member['Name'];
|
|
$rankedUser->ingameRole = $member['Rank'];
|
|
$rankedUser->lastSeen = Carbon::now();
|
|
if ($rankedUser->firstSeen === null)
|
|
$rankedUser->firstSeen = Carbon::now();
|
|
|
|
$rankedUser->save();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|