mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
WIP test notification
This commit is contained in:
@@ -13,7 +13,7 @@ use App\Invoice;
|
||||
use App\SettingCredit;
|
||||
use App\SettingTaxRate;
|
||||
use App\SettingBillingCharge;
|
||||
use App\Notification;
|
||||
use App\Notifications\BookingUpdated;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use DateTime;
|
||||
@@ -97,7 +97,9 @@ class BookingController extends Controller
|
||||
$booking->status_desc = $status_desc;
|
||||
$booking->marking = $booking->user->marking;
|
||||
}
|
||||
|
||||
|
||||
$user->notify(new BookingUpdated($booking));
|
||||
|
||||
return $bookings;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use App\Booking;
|
||||
|
||||
class BookingUpdated extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
protected $booking;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Booking $booking)
|
||||
{
|
||||
$this->booking = $booking;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database', 'broadcast'];
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the mail representation of the notification.
|
||||
// *
|
||||
// * @param mixed $notifiable
|
||||
// * @return \Illuminate\Notifications\Messages\MailMessage
|
||||
// */
|
||||
// public function toMail($notifiable)
|
||||
// {
|
||||
// return (new MailMessage)
|
||||
// ->line('The introduction to the notification.')
|
||||
// ->action('Notification Action', url('/'))
|
||||
// ->line('Thank you for using our application!');
|
||||
// }
|
||||
|
||||
public function toDatabase($notifiable)
|
||||
{
|
||||
return [
|
||||
'booking_id' => $this->booking->id
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
'booking' => $this->booking,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,7 +108,7 @@ export default {
|
||||
pagination: [],
|
||||
}),
|
||||
mounted () {
|
||||
//this.listen()
|
||||
this.listen()
|
||||
},
|
||||
computed: mapGetters({
|
||||
user: 'auth/user'
|
||||
@@ -191,13 +191,22 @@ export default {
|
||||
Authorization: 'Bearer ' + localStorage.getItem("token")
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
console.log(this.user.id)
|
||||
window.Echo.private('App.User.' + this.user.id)
|
||||
.notification((notification) => {
|
||||
console.log(notification);
|
||||
});
|
||||
|
||||
// window.Echo.channel('private-App.User.' + this.user.id)
|
||||
// .listen((notification) => {
|
||||
// console.log(notification);
|
||||
// });
|
||||
|
||||
// window.Echo.channel('private-App.User.' + this.user.id)
|
||||
// .listen('BroadcastNotificationCreated', response => {
|
||||
// if (! ('Notification' in window)) {
|
||||
// alert('Web Notification is not supported');
|
||||
// return;
|
||||
// }
|
||||
// console.log(response)
|
||||
|
||||
// });
|
||||
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user