feat: Implement new way of fetching champ info

Introduced a new environment variable, MAMC_SECRET, to securely fetch champion data from an external API. This secret is now used in the ChampionSeeder, ChampionSkinSeeder and SkinChromaSeeder classes to authenticate requests. The .env.example and app configuration files have been updated accordingly.
This commit is contained in:
Rico van Zelst
2024-06-22 18:45:05 +02:00
parent 8f97d255dc
commit 87c0d4ca94
5 changed files with 24 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ use App\Models\SkinChroma;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Http;
class SkinChromaSeeder extends Seeder
{
@@ -14,8 +15,12 @@ class SkinChromaSeeder extends Seeder
*/
public function run(): void
{
$championDataUrl = 'https://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json';
$championData = json_decode(file_get_contents($championDataUrl), true);
$mamcSecret = config('app.MAMC_SECRET');
$championDataUrl = 'https://mamchamp.orianna.dev/champion-data';
$championData = Http::withHeaders([
'MAM-Get-Secret' => $mamcSecret,
])->get($championDataUrl)->json();
$changeCount = 0;
foreach ($championData as $champion) {