orderby('id','desc'); $consulta_configuracion = Configuracione::with('usuario')->orderby('id', 'desc')->first(); $this->consulta_configuracion = $consulta_configuracion; //dd($consulta_configuraciones); if (empty($this->nombre) && empty($this->slogan) && empty($this->color_boton)) { $this->nombre = $consulta_configuracion->nombre; $this->slogan = $consulta_configuracion->slogan; $this->color_boton = $consulta_configuracion->color_boton; $this->url_logo = $consulta_configuracion->url_logo; $this->color_barra = $consulta_configuracion->color_barra; $this->color_menu = $consulta_configuracion->color_menu; //top $this->top_1 = $consulta_configuracion->top_1; $this->top_2 = $consulta_configuracion->top_2; $this->top_3 = $consulta_configuracion->top_3; $this->top_4 = $consulta_configuracion->top_4; $this->top_5 = $consulta_configuracion->top_5; $this->top_6 = $consulta_configuracion->top_6; $this->top_7 = $consulta_configuracion->top_7; $this->top_8 = $consulta_configuracion->top_8; $this->top_9 = $consulta_configuracion->top_9; $this->top_10 = $consulta_configuracion->top_10; $this->premio_1 = $consulta_configuracion->premio_1; $this->premio_2 = $consulta_configuracion->premio_2; $this->premio_3 = $consulta_configuracion->premio_3; $this->premio_4 = $consulta_configuracion->premio_4; $this->premio_5 = $consulta_configuracion->premio_5; $this->premio_6 = $consulta_configuracion->premio_6; $this->premio_7 = $consulta_configuracion->premio_7; $this->premio_8 = $consulta_configuracion->premio_8; $this->premio_9 = $consulta_configuracion->premio_9; $this->premio_10 = $consulta_configuracion->premio_10; $this->img_top = $consulta_configuracion->img_top; $this->mensaje_top = $consulta_configuracion->mensaje_top; //msj $this->mensaje_msj_compra = $consulta_configuracion->msj_compra; $this->mensaje_msj_wp = $consulta_configuracion->msj_wp; $this->clave_1 = $consulta_configuracion->clave_1; $this->clave_2 = $consulta_configuracion->clave_2; $this->clave_3 = $consulta_configuracion->clave_3; $this->clave_4 = $consulta_configuracion->clave_4; $this->clave_5 = $consulta_configuracion->clave_5; $this->clave_6 = $consulta_configuracion->clave_6; $this->iptv = $consulta_configuracion->iptv; $this->notificacion = $consulta_configuracion->hora; } return view('livewire.show-configuracion', [ 'sliders' => slider::get(), 'usuarios' => User::get(), ]); } public function updateCatalogo() { if ($this->catalogo) { // Generar un nombre aleatorio para el nuevo catálogo $nombreCatalogo = Str::random(10) . '.pdf'; // Almacenar el nuevo archivo y obtener su URL $urlCatalogo = $this->catalogo->storeAs('photos', $nombreCatalogo); } else { // Mantener la URL del archivo anterior $urlCatalogo = $this->consulta_configuracion->catalogo; } // Actualizar el campo de catálogo en la configuración $this->consulta_configuracion->catalogo = $urlCatalogo; $this->consulta_configuracion->save(); // Mostrar un mensaje de éxito $this->alert('success', '¡Catálogo actualizado correctamente!', [ 'position' => 'top' ]); } public function guardarNoti() { $this->validate([ 'titulo_noti' => 'required', 'descripcion_noti' => 'required', ]); $consulta = new Notificacion(); $consulta->remitente_id = Auth::user()->id; $consulta->destinatario_id = $this->destinatario_noti == 'todos' ? Auth::user()->id : $this->destinatario_noti; $consulta->titulo = trim($this->titulo_noti); $consulta->descripcion = trim($this->descripcion_noti); $consulta->estado = true; $consulta->todos = $this->destinatario_noti == 'todos' || !$this->destinatario_noti ? true : false; $consulta->save(); $this->alert('success', 'Notificacion creada exitosamente!', [ 'position' => 'top' ]); $this->titulo_noti = null; $this->descripcion_noti = null; $this->destinatario_noti = null; } public function guardarclaves() { $claves = $this->consulta_configuracion->update([ 'clave_1' => $this->clave_1, 'clave_2' => $this->clave_2, 'clave_3' => $this->clave_3, 'clave_4' => $this->clave_4, 'clave_5' => $this->clave_5, 'clave_6' => $this->clave_6, ]); if ($claves) { $this->alert('success', 'claves actualizado', [ 'position' => 'top' ]); } } public function guardar() { if (!empty($this->photo)) { $nombre = Str::random(10); $img = img::make($this->photo)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); $location = "photos/" . $nombre . ".webp"; Storage::disk('local')->put($location, $img); $url_logo = $location; } else { $url_logo = $this->url_logo; } $configuracion = $this->consulta_configuracion->update([ 'nombre' => $this->nombre, 'slogan' => $this->slogan, 'color_boton' => $this->color_boton, 'url_logo' => $url_logo, 'color_barra' => $this->color_barra, 'color_menu' => $this->color_menu, 'usermodifico_id' => Auth::user()->id, ]); if ($configuracion) { $this->alert('success', 'Configuración actualizada', [ 'position' => 'top' ]); } } public function guardarSlider() { if (!empty($this->slider)) { $nombre = Str::random(12); $img = img::make($this->slider)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); $location = "photos/" . $nombre . ".webp"; Storage::disk('local')->put($location, $img); $url_slider = $location; } else { $url_slider = ''; } $guardar = new slider; $guardar->slider = $url_slider; $guardar->save(); $this->slider = ''; } public function cancelarSlider() { $this->slider = ''; } public function deleteSlider($id) { $this->delete_slider = $id; $this->alert('warning', '¿Eliminar slider?', [ 'position' => 'center', 'timer' => '10000', 'toast' => false, 'text' => 'Esta seguro', 'showConfirmButton' => true, 'onConfirmed' => 'confirmed', 'showDenyButton' => false, 'onDenied' => '', 'showCancelButton' => true, 'onDismissed' => '', 'cancelButtonText' => 'Salir', 'confirmButtonText' => 'Si', 'customClass' => [ 'confirmButton' => 'bg-green-500', 'denyButton' => 'bg-red-500', 'cancelButton' => 'bg-gray-500', ] ]); } public function getListeners() { return [ 'confirmed' ]; } public function confirmed() { slider::where('id', $this->delete_slider)->delete(); $this->alert('success', 'Imagen eliminada correctamente!', [ 'position' => 'top' ]); } public function guardarTop() { if (!empty($this->photo_top)) { $nombre = Str::random(10); $img = img::make($this->photo_top)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); $location = "photos/" . $nombre . ".webp"; Storage::disk('local')->put($location, $img); $photo_top = $location; } else { $photo_top = $this->img_top; } if (!empty($this->imgP1)) { $imgP1 = $this->imgP1->store('photos'); } else { $imgP1 = $this->top_1; } if (!empty($this->imgP2)) { $imgP2 = $this->imgP2->store('photos'); } else { $imgP2 = $this->top_2; } if (!empty($this->imgP3)) { $imgP3 = $this->imgP3->store('photos'); } else { $imgP3 = $this->top_3; } if (!empty($this->imgP4)) { $imgP4 = $this->imgP4->store('photos'); } else { $imgP4 = $this->top_4; } if (!empty($this->imgP5)) { $imgP5 = $this->imgP5->store('photos'); } else { $imgP5 = $this->top_5; } if (!empty($this->imgP6)) { $imgP6 = $this->imgP6->store('photos'); } else { $imgP6 = $this->top_6; } if (!empty($this->imgP7)) { $imgP7 = $this->imgP7->store('photos'); } else { $imgP7 = $this->top_7; } if (!empty($this->imgP8)) { $imgP8 = $this->imgP8->store('photos'); } else { $imgP8 = $this->top_8; } if (!empty($this->imgP9)) { $imgP9 = $this->imgP9->store('photos'); } else { $imgP9 = $this->top_9; } if (!empty($this->imgP10)) { $imgP10 = $this->imgP10->store('photos'); } else { $imgP10 = $this->top_10; } $top = $this->consulta_configuracion->update([ 'top_1' => $imgP1, 'top_2' => $imgP2, 'top_3' => $imgP3, 'top_4' => $imgP4, 'top_5' => $imgP5, 'top_6' => $imgP6, 'top_7' => $imgP7, 'top_8' => $imgP8, 'top_9' => $imgP9, 'top_10' => $imgP10, 'img_top' => $photo_top, 'mensaje_top' => $this->mensaje_top, 'premio_1' => $this->premio_1, 'premio_2' => $this->premio_2, 'premio_3' => $this->premio_3, 'premio_4' => $this->premio_4, 'premio_5' => $this->premio_5, 'premio_6' => $this->premio_6, 'premio_7' => $this->premio_7, 'premio_8' => $this->premio_8, 'premio_9' => $this->premio_9, 'premio_10' => $this->premio_10, ]); if ($top) { $this->alert('success', 'Top distribuidores actualizado', [ 'position' => 'top' ]); } } public function guardarMsjCompra() { $msj = $this->consulta_configuracion->update([ 'msj_compra' => $this->mensaje_msj_compra, 'msj_wp' => $this->mensaje_msj_wp, ]); if ($msj) { $this->alert('success', 'Mensaje actualizado', [ 'position' => 'top' ]); } } public function guardariptv() { // dd($this->iptv); $iptv = $this->consulta_configuracion->update([ 'iptv' => $this->iptv, ]); if ($iptv) { $this->alert('success', 'iptv actualizado', [ 'position' => 'top' ]); } } public function eliminarC() { //$eliminar_cuentas = Cuentas::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' ]); } public function eliminarR() { // $eliminar_cuentas = Historial_cuenta::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' ]); } public function eliminarH() { //$desasociar_cuentas = Historiale::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' ]); } public function guardarnot() { $notificacion = $this->consulta_configuracion->update([ 'hora' => $this->notificacion, ]); $this->alert('success', 'La hora de notificación ha sido actualizada.', [ 'position' => 'top' ]); } public function eliminarCache() { Artisan::call('cache:clear'); Artisan::call('config:clear'); Artisan::call('view:clear'); Artisan::call('route:cache'); $this->alert('success', 'Cache removido correctamente', [ 'position' => 'top' ]); } }