-
-
Save fayqLs/ab90c7c041c6270a1c994bfff8222814 to your computer and use it in GitHub Desktop.
Mensagens SweetAlert2 no Sistema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# 1 - Adicione nas propriedades do projeto do Adianti Builder em Header Tags(script, style, meta) | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.min.css"> | |
# 2 - Depois crie uma classe service com o nome de Mensagem e cole esse código abaixo.. exemplo: | |
class Mensagem | |
{ | |
public static function OK($mensagem) | |
{ | |
$codigo = " | |
Swal.fire( | |
'Sucesso!', | |
'{$mensagem}', | |
'success' | |
) | |
"; | |
TScript::create($codigo); | |
} | |
public static function Sucesso($mensagem) | |
{ | |
$codigo = " | |
Swal.fire({ | |
position: 'center', | |
icon: 'success', | |
title: '{$mensagem}', | |
showConfirmButton: false, | |
timer: 1500 | |
}) | |
"; | |
TScript::create($codigo); | |
} | |
public static function Erro($mensagem) | |
{ | |
$codigo = " | |
Swal.fire( | |
'Erro Interno!', | |
'{$mensagem}', | |
'warning' | |
) | |
"; | |
TScript::create($codigo); | |
} | |
public static function Alerta($mensagem) | |
{ | |
$codigo = " | |
Swal.fire( | |
'ATENÇÃO!', | |
'{$mensagem}', | |
'warning' | |
) | |
"; | |
TScript::create($codigo); | |
} | |
} | |
# 3 - Por fim, basta usar o método desejado de acordo com o tipo de mensagem que você quer aplicar.. exemplo: | |
Mensagem::OK('Sua Mensagem'); | |
Mensagem::Sucesso('Sua Mensagem'); | |
Mensagem::Alerta('Sua Mensagem'); | |
Mensagem::Erro('Sua Mensagem'); | |
# Site oficial: https://sweetalert2.github.io/ | |
/* | |
Espero que tenha ajudado.. Valeu! : ) | |
Dúvidas ou suporte, é só chamar | |
https://wa.me/5583986556461 | |
Fabricio Almeida | |
Programador PHP, Desktop e Mobile | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment