mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: Add LMI API integration for fetching sales data
- Integrate LMI API to fetch current sales data using the provided API key. - Update SaleController to use Http facade for making API requests. - Modify services configuration to include LMI API key.
This commit is contained in:
@@ -14,6 +14,8 @@ APP_MAINTENANCE_STORE=database
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LMI_API_KEY=
|
||||
|
||||
APP_STAGING=false
|
||||
|
||||
OCTANE_SERVER=swoole
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SaleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$sales = Cache::remember('sales_data', 60 * 60 * 8, static function () {
|
||||
$shopData = json_decode(
|
||||
file_get_contents('https://rico-vz.github.io/shop-depr-temp/download.json'),
|
||||
true
|
||||
);
|
||||
$salesData = array_filter($shopData, static fn ($collection) => $collection['path'] === '/event/sales');
|
||||
$lmi_api_key = config('services.lmi.api_key');
|
||||
|
||||
return reset($salesData)['dynamicCollection']['discountedProductsByProductType'] ?? [];
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . $lmi_api_key,
|
||||
])->get('https://lmi.orianna.dev/api/lol-sales');
|
||||
|
||||
return $response->json();
|
||||
});
|
||||
|
||||
return view('sales.index', ['sales' => $sales]);
|
||||
|
||||
@@ -9,4 +9,8 @@ return [
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'lmi' => [
|
||||
'api_key' => env('LMI_API_KEY'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -4,63 +4,26 @@
|
||||
@endphp
|
||||
|
||||
<section class="max-w-screen-xl mx-auto mt-12">
|
||||
<h3 class="mt-8 mb-2 text-lg font-bold text-center text-transparent uppercase sm:text-xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">Sale Rotation is currently undergoing maintenance. This data is not up-to-date. Check back soon.</h3>
|
||||
|
||||
<h1
|
||||
class="text-3xl font-bold text-center text-transparent uppercase sm:text-4xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
Sale Rotation</h1>
|
||||
<h2 class="text-lg font-bold text-center text-transparent uppercase sm:text-xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">All champions & skins on sale</h2>
|
||||
<h2
|
||||
class="text-lg font-bold text-center text-transparent uppercase sm:text-xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
All champions & skins on sale</h2>
|
||||
|
||||
<h3 class="mt-8 mb-2 text-2xl font-bold text-center text-transparent uppercase sm:text-3xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">Champions on Sale</h3>
|
||||
<h3
|
||||
class="mt-8 mb-2 text-2xl font-bold text-center text-transparent uppercase sm:text-3xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
Champions on Sale</h3>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach($sales['CHAMPION'] as $sale)
|
||||
@foreach ($sales['champion_sales'] as $sale)
|
||||
@php
|
||||
$champion = Champion::where('champion_id', $sale['id'])->first();
|
||||
$originalPrice = $sale['prices'][0]['originalPrice']['cost'];
|
||||
$discountedPrice = $sale['prices'][0]['discount']['discountedProductPrice']['cost'];
|
||||
$discountPercentage = round((1 - ($discountedPrice / $originalPrice)) * 100);
|
||||
$champion = Champion::where('champion_id', $sale['item_id'])->first();
|
||||
$discountPercentage = $sale['percent_off'];
|
||||
$discountedPrice = $sale['rp'];
|
||||
@endphp
|
||||
<a href="/champion/{{$champion->slug}}">
|
||||
<div
|
||||
class="flex flex-col items-center text-gray-700 border shadow-md bg-stone-800/40 rounded-2xl bg-clip-border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||
<div class="absolute px-3 py-1 mt-4 text-white rounded-full bg-black/60">
|
||||
{{ $discountPercentage }}% Off
|
||||
</div>
|
||||
<div
|
||||
class="w-auto mx-4 mt-3 overflow-hidden border-2 rounded-2xl bg-clip-border border-orange-400/40 aspect-video">
|
||||
<img
|
||||
src="//wsrv.nl/?url={{ $champion->getChampionImageAttribute() }}&w=450&output=webp&q=80&il&default=ssl:wsrv.nl%2F%3Furl%3Dhttps://i.ibb.co/5s6YyvN/aaaa.png"
|
||||
class="aspect-video"
|
||||
alt="{{ $champion->name }} Splash Art"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<div class="px-4 py-2">
|
||||
<div class="flex">
|
||||
<p class="block text-sm antialiased font-medium text-left text-gray-100">
|
||||
<span class="font-bold text-orange-400">{{ $champion->name }}</span> •
|
||||
{{ $discountedPrice }} RP
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
<h3 class="mt-8 text-2xl font-bold text-center text-transparent uppercase sm:text-3xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">Skins on Sale</h3>
|
||||
<div class="container flex flex-col items-center justify-center p-4 mx-auto text-white">
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach($sales['CHAMPION_SKIN'] as $sale)
|
||||
@php
|
||||
$skin = ChampionSkin::where('full_skin_id', $sale['id'])->first();
|
||||
$originalPrice = $sale['prices'][0]['originalPrice']['cost'];
|
||||
$discountedPrice = $sale['prices'][0]['discount']['discountedProductPrice']['cost'];
|
||||
$discountPercentage = round((1 - ($discountedPrice / $originalPrice)) * 100);
|
||||
@endphp
|
||||
<a href="/skin/{{ $skin->slug }}">
|
||||
<a href="/champion/{{ $champion->slug }}">
|
||||
<div
|
||||
class="flex flex-col items-center text-gray-700 border shadow-md bg-stone-800/40 rounded-2xl bg-clip-border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||
<div class="absolute px-3 py-1 mt-4 text-white rounded-full bg-black/60">
|
||||
@@ -68,23 +31,57 @@
|
||||
</div>
|
||||
<div
|
||||
class="w-auto mx-4 mt-3 overflow-hidden border-2 rounded-2xl bg-clip-border border-orange-400/40 aspect-video">
|
||||
<img
|
||||
src="//wsrv.nl/?url={{ $skin->getSkinImageAttribute() }}&w=450&output=webp&q=80&il&default=ssl:wsrv.nl%2F%3Furl%3Dhttps://i.ibb.co/5s6YyvN/aaaa.png"
|
||||
class="aspect-video"
|
||||
alt="{{ $skin->skin_name }} Splash Art"
|
||||
/>
|
||||
<img src="//wsrv.nl/?url={{ $champion->getChampionImageAttribute() }}&w=450&output=webp&q=80&il&default=ssl:wsrv.nl%2F%3Furl%3Dhttps://i.ibb.co/5s6YyvN/aaaa.png"
|
||||
class="aspect-video" alt="{{ $champion->name }} Splash Art" />
|
||||
|
||||
</div>
|
||||
<div class="px-4 py-2">
|
||||
<div class="flex">
|
||||
<p class="block text-sm antialiased font-medium text-left text-gray-100">
|
||||
<span class="font-bold text-orange-400">{{ $skin->skin_name }}</span> •
|
||||
<span class="font-bold text-orange-400">{{ $champion->name }}</span> •
|
||||
{{ $discountedPrice }} RP
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
<h3
|
||||
class="mt-8 text-2xl font-bold text-center text-transparent uppercase sm:text-3xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
|
||||
Skins on Sale</h3>
|
||||
<div class="container flex flex-col items-center justify-center p-4 mx-auto text-white">
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach ($sales['skin_sales'] as $sale)
|
||||
@php
|
||||
$skin = ChampionSkin::where('full_skin_id', $sale['item_id'])->first();
|
||||
$discountPercentage = $sale['percent_off'];
|
||||
$discountedPrice = $sale['rp'];
|
||||
@endphp
|
||||
<a href="/skin/{{ $skin->slug }}">
|
||||
<div
|
||||
class="flex flex-col items-center text-gray-700 border shadow-md bg-stone-800/40 rounded-2xl bg-clip-border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||
<div class="absolute px-3 py-1 mt-4 text-white rounded-full bg-black/60">
|
||||
{{ $discountPercentage }}% Off
|
||||
</div>
|
||||
<div
|
||||
class="w-auto mx-4 mt-3 overflow-hidden border-2 rounded-2xl bg-clip-border border-orange-400/40 aspect-video">
|
||||
<img src="//wsrv.nl/?url={{ $skin->getSkinImageAttribute() }}&w=450&output=webp&q=80&il&default=ssl:wsrv.nl%2F%3Furl%3Dhttps://i.ibb.co/5s6YyvN/aaaa.png"
|
||||
class="aspect-video" alt="{{ $skin->skin_name }} Splash Art" />
|
||||
|
||||
</div>
|
||||
<div class="px-4 py-2">
|
||||
<div class="flex">
|
||||
<p class="block text-sm antialiased font-medium text-left text-gray-100">
|
||||
<span class="font-bold text-orange-400">{{ $skin->skin_name }}</span> •
|
||||
{{ $discountedPrice }} RP
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user