File size: 1,800 Bytes
52d9fb0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <link href="{{ asset('assets/global/css/iziToast.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/global/css/iziToast_custom.css') }}" rel="stylesheet">
<script src="{{ asset('assets/global/js/iziToast.min.js') }}"></script>
<script>
"use strict";
const colors = {
success: '#28c76f',
error: '#eb2222',
warning: '#ff9f43',
info: '#1e9ff2',
}
const icons = {
success: 'fas fa-check-circle',
error: 'fas fa-times-circle',
warning: 'fas fa-exclamation-triangle',
info: 'fas fa-exclamation-circle',
}
const notifications = @json(session('notify', []));
const errors = @json(@$errors ? collect($errors->all())->unique() : []);
const triggerToaster = (status, message) => {
iziToast[status]({
title: status.charAt(0).toUpperCase() + status.slice(1),
message: message,
position: "topRight",
backgroundColor: '#fff',
icon: icons[status],
iconColor: colors[status],
progressBarColor: colors[status],
titleSize: '1rem',
messageSize: '1rem',
titleColor: '#474747',
messageColor: '#a2a2a2',
transitionIn: 'obunceInLeft',
});
}
if (notifications.length) {
notifications.forEach(element => {
triggerToaster(element[0], element[1]);
});
}
if (errors.length) {
errors.forEach(error => {
triggerToaster('error', error);
});
}
function notify(status, message) {
if (typeof message == 'string') {
triggerToaster(status, message);
} else {
$.each(message, (i, val) => triggerToaster(status, val));
}
}
</script>
|