Files
HeimerdingerLoL/app/Http/Controllers/SaleController.php
2023-12-05 14:41:37 +00:00

25 lines
715 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Cache;
class SaleController extends Controller
{
public function index()
{
$sales = Cache::remember('sales_data', 60 * 60 * 8, function () {
$shopData = json_decode(
file_get_contents('https://api.shop.riotgames.com/v3/collections/'),
true
);
$salesData = array_filter($shopData, function ($collection) {
return $collection['path'] === '/event/sales';
});
return reset($salesData)['dynamicCollection']['discountedProductsByProductType'] ?? [];
});
return view('sales.index', compact('sales'));
}
}