<?php if(session()->has('notify')): ?>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function () {
            let notify = <?php echo json_encode(session('notify'), 15, 512) ?>;
            if (notify.length > 0) {
                showNotification(notify[0][0], notify[0][1]);
            }
        });
    </script>
<?php endif; ?>

<?php if($errors->any()): ?>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function () {
            let errors = <?php echo json_encode($errors->all(), 15, 512) ?>;
            if (errors.length > 0) {
                showNotification('error', errors[0]);
            }
        });
    </script>
<?php endif; ?>

<script type="text/javascript">
    function showNotification(type, message) {
        Toastify({
            text: message,
            duration: 3000, // Duration in milliseconds
            gravity: 'top', // Position: 'top', 'bottom', 'center'
            position: 'right', // Position: 'left', 'center', 'right'
            backgroundColor: type === 'success' ? '#28a745' : '#dc3545', // Background color
        }).showToast();
    }

    // Example usage:
    // showNotification('success', 'Operation successful!');
    // showNotification('error', 'An error occurred.');
</script>
<script src="<?php echo e(URL::asset('build/js/pages/notifications.init.js')); ?>"></script>
<?php /**PATH /home/paysafebd23/merchant.zigopay.net/resources/views/layouts/notify.blade.php ENDPATH**/ ?>