how about using flash messages with vue?do u use vue in your project? u can use this
Flash.vue
<template>
<div class="alert alert-flash" :class="'alert-'+level" role="alert" style="padding-right:20px; padding-left:20px" v-show="show" v-text="body">
</div>
</template>
<script>
export default {
props: ["message", "levels"],
data() {
return {
body: this.message,
level: this.levels,
show: false
};
},
created() {
if (this.message) {
this.flash();
}
},
methods: {
flash() {
this.show = true;
this.hide();
},
hide() {
setTimeout(() => {
this.show = false;
}, 4000);
}
}
};
</script>
<style>
.alert-flash {
position: fixed;
right: 25px;
bottom: 25px;
}
</style>
register the component in app.js
Vue.component('flash', require('./components/Flash.vue'));
const app = new Vue({
el: '#app',
});
in your main layout under id app put this
<div id='app'>
<flash levels="{{session('level','success')}}" message="{{session('flash')}}"></flash>
</div>
when you store in session you have to pass one message property it will by default success message . if you want danger message you have to pass levels prop as well
example
return back()->with(['levels'=>'danger', 'message'=>'sorry, permission denied'])