<?php

declare(strict_types=1);

use Hypervel\Support\Facades\Route;

use App\Http\Controllers\LoginController;
use Hypervel\Support\Facades\Auth;

use App\Models\User;

use Hypervel\Support\Facades\Cache;

use Hypervel\Support\Facades\Config;

use Hypervel\Support\Facades\Response;


use Hyperf\Redis\RedisFactory;
use Psr\Http\Message\ResponseInterface;

use Hypervel\Support\Facades\Session;

use Hypervel\Http\Request;


// Route::get('/dev-login/{mobile}', function ($mobile) {
//     $user = User::where('mobile_number', $mobile)->first();

//     if (!$user) {
//         return response()->json(['success' => false, 'message' => 'User not found.'], 404);
//     }

//     Auth::login($user);
//     // request()->session();

//         request()->session()->regenerate();
//     return response()->json([
//         'success' => true,
//         'message' => "Logged in as {$user->name} (ID: {$user->id})",
//         'session_id' => request()->session()->getId(),
//         'session_data' => request()->session()->all(),
//         'cookie_name' => config('session.cookie'),
//         'auth_check' => Auth::check(),
//         'user' => Auth::user(),
//     ]);
// }, ['middleware' => 'web']);





// Route::get('/debug-redis-config', function () {
//     return response()->json([
//         'redis' => Config::get('database.redis'),
//     ]);
// }, ['middleware' => 'web']);


// Route::get('/test-redis', function (RedisFactory $redisFactory): ResponseInterface {//works
//     $redis = $redisFactory->get('default');
//     $redis->set('test_key', '✅ Redis connection works!');
//     $value = $redis->get('test_key');

//     return Response::json(['value' => $value]);
// }, ['middleware' => 'web']);

// Route::get('/test-redis-cache', function () {//same error about ivalid redis proxy
//     Cache::put('redis_test_key', 'bukidbounty_works', 600); // store for 10 mins
//     return response()->json(['status' => 'Cache written to Redis']);
// }, ['middleware' => 'web']);


// Route::get('/session-check', function () {
//     return response()->json([
//         'authenticated' => Auth::check(),
//         'user' => Auth::user(),
//         'session_id' => Session::getId(),
//     ]);
// });


// Route::get('/debug-session', function (Request $request) {
//     return Response::json([
//         'session_id' => $request->session()->getId(),
//         'session_data' => $request->session()->all(),
//         'cookie_name' => config('session.cookie'),
//         'auth_check' => Auth::check(),
//         'user' => Auth::user(),
//         'acct_type' => Auth::user()->acct_type,
//     ]);
// });


// Route::get('/session-check', fn() => response()->json(session()->all()), ['middleware' => 'web']);
