mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
removed some .env-example duplication config
updated rate updated event added listener to user home page
This commit is contained in:
@@ -13,11 +13,6 @@ DB_DATABASE=default
|
||||
DB_USERNAME=default
|
||||
DB_PASSWORD=secret
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use App\Rate;
|
||||
|
||||
class RateUpdated implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $rate;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Rate $rate)
|
||||
{
|
||||
$this->rate = $rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('rate-updated');
|
||||
//return new PrivateChannel('rate-updated');
|
||||
}
|
||||
|
||||
public function broadcastWith() {
|
||||
return [
|
||||
'rate' => $this->rate,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class RateUpdated extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\Events\RateUpdated;
|
||||
|
||||
class RateObserver
|
||||
{
|
||||
/**
|
||||
* Handle the rate "created" event.
|
||||
*
|
||||
* @param \App\Rate $rate
|
||||
* @return void
|
||||
*/
|
||||
public function created(Rate $rate)
|
||||
{
|
||||
event(new RateUpdated($rate));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace App\Providers;
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Observers\RateObserver;
|
||||
use App\Rate;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -21,6 +23,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
*/
|
||||
Rate::observe(RateObserver::class);
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
//Broadcast::routes();
|
||||
Broadcast::routes(["middleware" => ["auth:api"]]);
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ export default {
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,11 +108,6 @@ export default {
|
||||
computed: mapGetters({
|
||||
user: 'auth/user'
|
||||
}),
|
||||
mounted(){
|
||||
if(this.user){
|
||||
//this.getNotification(this.url)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async logout(){
|
||||
// Log out the user.
|
||||
@@ -121,15 +116,15 @@ export default {
|
||||
// Redirect to login.
|
||||
this.$router.push({ name: 'login' });
|
||||
},
|
||||
refreshNoti() {
|
||||
axios.get(this.url).then(response => {
|
||||
this.bookingTable = response.data.data
|
||||
this.notification = response.data.message.data;
|
||||
this.bellBadge = response.data.unread_message.length;
|
||||
this.makePagination(response.data.message);
|
||||
console.log(response.data);
|
||||
})
|
||||
},
|
||||
// refreshNoti() {
|
||||
// axios.get(this.url).then(response => {
|
||||
// this.bookingTable = response.data.data
|
||||
// this.notification = response.data.message.data;
|
||||
// this.bellBadge = response.data.unread_message.length;
|
||||
// this.makePagination(response.data.message);
|
||||
// console.log(response.data);
|
||||
// })
|
||||
// },
|
||||
// getNotification(url){
|
||||
// this.notification = [];
|
||||
// this.loadingNotification=true;
|
||||
@@ -191,7 +186,7 @@ export default {
|
||||
// },
|
||||
navigateTo(nav) {
|
||||
window.location.href = nav;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import store from '~/store'
|
||||
|
||||
export default (to, from, next) => {
|
||||
console.log(store.getters['auth/role'])
|
||||
if (store.getters['auth/role'] !== 'admin') {
|
||||
next({ name: 'home' })
|
||||
} else {
|
||||
|
||||
@@ -402,6 +402,8 @@ import Form from 'vform'
|
||||
import LoginWithGithub from '~/components/LoginWithGithub'
|
||||
import store from '~/store'
|
||||
import axios from 'axios'
|
||||
import Echo from "laravel-echo"
|
||||
import Pusher from "pusher-js"
|
||||
|
||||
export default {
|
||||
middleware: ['auth'],
|
||||
@@ -526,8 +528,40 @@ export default {
|
||||
this.initBooking();
|
||||
this.getRate();
|
||||
this.getCompleteBooking();
|
||||
this.listen();
|
||||
},
|
||||
methods: {
|
||||
// listen to update rate changes
|
||||
listen(){
|
||||
window.Echo = new Echo({
|
||||
broadcaster: 'pusher',
|
||||
key: '20cae353616471c0c765',
|
||||
cluster: 'ap1',
|
||||
encrypted: true,
|
||||
auth: {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + localStorage.getItem("token")
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
window.Echo.channel('rate-updated')
|
||||
.listen('RateUpdated', response => {
|
||||
if (! ('Notification' in window)) {
|
||||
alert('Web Notification is not supported');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: 'New rate updated at ' + response.rate.created_at,
|
||||
duration: 20000
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
getBooking(){
|
||||
let $this = this
|
||||
axios.get(this.url).then(response => {
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||
return (int) $user->id === (int) $id;
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user