Files
HeimerdingerLoL/app/Http/Controllers/SaleController.php
Rico van Zelst 48c74fb4d6 feat(sales): WIP: add SaleController, Current_sales component, and view
- Added a new file `SaleController.php` in the `app/Http/Controllers` directory to handle sales-related logic.
- Created a new file `Current_sales.php` in the `app/View/Components/Sales` directory to define the `Current_sales` component.
- Added a new file `current_sales.blade.php` in the `resources/views/components/sales` directory to display the current sales.
- Modified the `web.php` routes file to include a route for accessing the sales page.

These changes introduce functionality related to displaying and managing sales data on the website.
2023-12-05 13:35:59 +01:00

22 lines
684 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'));
}
}