diff --git a/.env b/.env index 872cae5..1e1649d 100644 --- a/.env +++ b/.env @@ -17,7 +17,7 @@ DB_USERNAME=adminprime DB_PASSWORD=Orionpax9 DB_SSLCA=DigiCertGlobalRootCA.crt.pem -BROADCAST_DRIVER=log +BROADCAST_DRIVER=pusher CACHE_DRIVER=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync @@ -45,13 +45,13 @@ AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= +PUSHER_APP_ID=1774971 +PUSHER_APP_KEY=19d773bf0fcaed00027c +PUSHER_APP_SECRET=a6d6ac4f18b294965d80 PUSHER_HOST= PUSHER_PORT=443 PUSHER_SCHEME=https -PUSHER_APP_CLUSTER=mt1 +PUSHER_APP_CLUSTER=ap2 VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" VITE_PUSHER_HOST="${PUSHER_HOST}" diff --git a/app/Http/Controllers/ApiUaqrooController.php b/app/Http/Controllers/ApiUaqrooController.php index 5570c40..7e68414 100644 --- a/app/Http/Controllers/ApiUaqrooController.php +++ b/app/Http/Controllers/ApiUaqrooController.php @@ -8,6 +8,7 @@ use App\Models\User; use Carbon\Carbon; use App\Notifications\AccesoNoAutorizadoNotification; +use Illuminate\Support\Str; class ApiUaqrooController extends Controller @@ -59,8 +60,10 @@ public function buscarUsuario($email, $areaId) $e = new EventosAcceso; $e->area_id = $areaId; $e->usuario_id = $user_id; - $e->fecha_hora = now(); - + $e->fecha_hora = Carbon::now(); + $e->updated_at = Carbon::now(); + $e->created_at = Carbon::now(); + $e->evento_id = $this->generateEventoId(); if($user) { $validacion = Autorizaciones::where('usuario_id', $user_id) @@ -81,15 +84,25 @@ public function buscarUsuario($email, $areaId) $e->permiso = 'NO PERMITIDO'; $e->save(); - $user->notify(new AccesoNoAutorizadoNotification()); + // $user->notify(new AccesoNoAutorizadoNotification()); return response()->json(['acceso' => false]); } }else { return response()->json(['Usuario no encontrado']); } - } + + public function generateEventoId() + { + $maxValue = 999999999; + + do { + $randomNumber = random_int(1, $maxValue); // Puedes ajustar el rango según tus necesidades + } while (EventosAcceso::where('evento_id', $randomNumber)->exists()); + + return $randomNumber; } + } diff --git a/app/Http/Controllers/DashController.php b/app/Http/Controllers/DashController.php index 500afa2..24841c5 100644 --- a/app/Http/Controllers/DashController.php +++ b/app/Http/Controllers/DashController.php @@ -28,8 +28,8 @@ public function index() ->count(); $total = $conteo_permitido + $conteo_denegado; - $porcentaje_perm = ($conteo_permitido / $total) * 100; - $porcentaje_deneg = ($conteo_denegado / $total) * 100; + $porcentaje_perm = $total == 0 ? 0 : ($conteo_permitido / $total) * 100; + $porcentaje_deneg = $total == 0 ? 0 : ($conteo_denegado / $total) * 100; // Crear gráfico semanal $eventos_m = EventosAcceso::accesosSemanalesM(); diff --git a/config/database.php b/config/database.php index dd8c832..e2b12eb 100644 --- a/config/database.php +++ b/config/database.php @@ -15,7 +15,7 @@ | */ - 'default' => env('DB_CONNECTION', 'localhost'), + 'default' => env('DB_CONNECTION', 'mysql'), /* |--------------------------------------------------------------------------