Skip to content

Commit 0cafce9

Browse files
init:commit Finchnotification
1 parent d38fde5 commit 0cafce9

12 files changed

+314
-20
lines changed

app/Notifications/NewOrder.php

+17-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct($order)
3232
*/
3333
public function via($notifiable)
3434
{
35-
$notification_channel = 'database';
35+
$notification_channel = 'database,broadcast';
3636
$channel = explode(',' , $notification_channel);
3737
return $channel;
3838
}
@@ -51,13 +51,20 @@ public function toMail($notifiable)
5151
->line('Thank you for using our application!');
5252
}
5353

54-
public function toDatabase($notifiable)
55-
{
56-
return [
57-
'data' => 'Thare is new Order ('.$this->order->user->name.') With Number (#'.$this->order->id.')',
58-
'url' => URL('/'),
59-
];
60-
}
54+
// public function toDatabase($notifiable)
55+
// {
56+
// return [
57+
// 'data' => 'Thare is new Order ('.$this->order->user->name.') With Number (#'.$this->order->id.')',
58+
// 'url' => URL('/'),
59+
// ];
60+
// }
61+
// public function toBroadcast($notifiable)
62+
// {
63+
// return [
64+
// 'data' => 'Thare is new Order ('.$this->order->user->name.') With Number (#'.$this->order->id.')',
65+
// 'url' => URL('/'),
66+
// ];
67+
// }
6168
/**
6269
* Get the array representation of the notification.
6370
*
@@ -67,7 +74,8 @@ public function toDatabase($notifiable)
6774
public function toArray($notifiable)
6875
{
6976
return [
70-
//
77+
'data' => 'Thare is new Order ('.$this->order->user->name.') With Number (#'.$this->order->id.')',
78+
'url' => URL('/'),
7179
];
7280
}
7381
}

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"laravel/tinker": "^2.7",
1414
"laravel/ui": "^4.2",
1515
"mcamara/laravel-localization": "^1.7",
16+
"pusher/pusher-php-server": "^7.2",
1617
"simplesoftwareio/simple-qrcode": "~4"
1718
},
1819
"require-dev": {

composer.lock

+198-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
*/
192192
App\Providers\AppServiceProvider::class,
193193
App\Providers\AuthServiceProvider::class,
194-
// App\Providers\BroadcastServiceProvider::class,
194+
App\Providers\BroadcastServiceProvider::class,
195195
App\Providers\EventServiceProvider::class,
196196
App\Providers\RouteServiceProvider::class,
197197

package-lock.json

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
"@popperjs/core": "^2.11.6",
99
"axios": "^1.1.2",
1010
"bootstrap": "^5.2.3",
11+
"laravel-echo": "^1.15.0",
1112
"laravel-vite-plugin": "^0.7.2",
1213
"lodash": "^4.17.19",
1314
"postcss": "^8.1.14",
15+
"pusher-js": "^8.0.1",
1416
"sass": "^1.56.1",
1517
"vite": "^4.0.0"
1618
}

resources/js/app.js

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
import './bootstrap';
2+
3+
4+
Echo.private('App.Models.User.' + userId)
5+
.notification((notification) => {
6+
toastr.success(notification.data)
7+
// console.log(notification.type);
8+
});

0 commit comments

Comments
 (0)