Add all files
This commit is contained in:
27
app/Livewire/Traits/HasNotifications.php
Normal file
27
app/Livewire/Traits/HasNotifications.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
trait HasNotifications
|
||||
{
|
||||
public function bootHasNotifications()
|
||||
{
|
||||
if (Session::has('notification')) {
|
||||
$this->notify(
|
||||
Session::get('notification')['message'],
|
||||
Session::get('notification')['type']
|
||||
);
|
||||
Session::forget('notification');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifications
|
||||
*/
|
||||
public function notify($message, $type = 'success')
|
||||
{
|
||||
$this->dispatch('notify', ['message' => $message, 'type' => $type]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user