diff --git a/app/Http/Livewire/Admin/Menu/Level.php b/app/Http/Livewire/Admin/Menu/Level.php index bfcc53b..c0a429b 100644 --- a/app/Http/Livewire/Admin/Menu/Level.php +++ b/app/Http/Livewire/Admin/Menu/Level.php @@ -52,6 +52,7 @@ public function submit(){ $this->resetForm(); $this->resetInput(); $this->dispatchBrowserEvent('FirstModel',['show'=>false]); + $this->dispatchBrowserEvent('Toast',['show'=>true,'type'=>'success','message'=>"'".$level->name."'".' was added to Menu Level!']); } public function render() diff --git a/app/View/Components/Item/Toast.php b/app/View/Components/Item/Toast.php new file mode 100644 index 0000000..06d94a3 --- /dev/null +++ b/app/View/Components/Item/Toast.php @@ -0,0 +1,28 @@ +id(); - $table->timestamps(); $table->string('name'); + $table->timestamps(); }); } diff --git a/resources/js/components/main.js b/resources/js/components/main.js index 6f4e778..0157dd1 100644 --- a/resources/js/components/main.js +++ b/resources/js/components/main.js @@ -9,6 +9,7 @@ export function Main(data) { return { darkMode: data.darkMode, isSidebarOpen: false, + toast:{'show':false,'type':'normal','message':'Some message!'}, isFirstModelButtonClicked: false, init() { @@ -18,13 +19,33 @@ export function Main(data) { console.log(this.isFirstModelButtonClicked); }); }, + + toastNotification() { + if(this.toast.show === true){ + setTimeout(() => { + this.toast.show = false + }, 5000) + } + }, + eventToListen() { - console.log('hello'); + + // First Model window.addEventListener('FirstModel', event => { if (event.detail.show === false) { this.isFirstModelButtonClicked = false } }); + + // Toast + window.addEventListener('Toast', event => { + if (event.detail.show === true) { + this.toast.show=true + this.toast.type=event.detail.type; + this.toast.message=event.detail.message; + this.toastNotification(); + } + }); } } } diff --git a/resources/views/components/item/toast.blade.php b/resources/views/components/item/toast.blade.php new file mode 100644 index 0000000..32e188b --- /dev/null +++ b/resources/views/components/item/toast.blade.php @@ -0,0 +1,67 @@ + +
+