%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex_o/production/app/Http/Controllers/
Upload File :
Create Path :
Current File : /www/loslex_o/production/app/Http/Controllers/CupResultsController.php

<?php

namespace App\Http\Controllers;

use App\Models\Contest;
use App\Workers\Cup\LosCupProcessor;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;

if(!defined('RESULTS_CACHE_TTL'))
        define('RESULTS_CACHE_TTL', 7 * 24 * 3600);

class CupResultsController extends Controller
{
    public static $cacheKey = 'cup/handgun/2024';

    public function results()
    {
        $data = Cache::remember(self::$cacheKey, RESULTS_CACHE_TTL, function ()
        {
            Log::info("Cache MISS", ['key' => self::$cacheKey]);
            $processor = new LosCupProcessor();
            $contests = Contest::whereBetween('date', [Date::createFromDate(2023, 9, 01), Date::createFromDate(2024, 8, 31)])
                ->where('contest_category_id', 1)
                ->where('contest_level_id', 2)
                ->where('published', 1)
                ->getModels();
            return  $processor->ProcessCupResults($contests);
        });

        return view("cup.los", ['cup' => $data]);
    }

    public function clear()
    {
        if (Auth::user() && Auth::user()->is_admin) {
            Log::info("Cache clear - manual", ['key' => self::$cacheKey]);
            Cache::forget(self::$cacheKey);
        }

        return redirect(route('cup.results'));
    }
}

Zerion Mini Shell 1.0