-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFakeScreenChannel.php
More file actions
68 lines (63 loc) · 1.75 KB
/
FakeScreenChannel.php
File metadata and controls
68 lines (63 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Mediumart\Notifier\Examples;
use Illuminate\Notifications\Notification;
/**
* Use this class to quickly **taste** the package.
* register the channel as explained in the documentation in App\Providers\AppServiceProvider:
*
* public $notificationsChannels = [
* \Mediumart\Notifier\Examples\FakeScreenChannel::class
* ]
*
* create a new notification:
* `$ php artisan make:notification SomethingHappenedNotification`
*
* open the newly created notification class, and add the hook 'screen' to the `via`method:
* public function via($notifiable)
* {
* return ['screen'];
* }
*
* define a `toScreen` method that returns whatever message you want:
* public function toScreen($notifiable)
* {
* return 'Thank you for using our application!';
* }
*
* now this message will just be dumped to the screen when you notify any notifiable
* instance of the `SomethingHappenedNotification`.
*/
class FakeScreenChannel
{
/**
* Send the given notification.
*
* @param $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return void
*/
public function send($notifiable, Notification $notification)
{
dd($notification->toScreen($notifiable));
}
/**
* Check for the factory capacity.
*
* @param string $driver
* @return bool
*/
public static function canHandleNotification($driver)
{
return in_array($driver, ['screen']);
}
/**
* Create a new driver instance.
*
* @param $driver
* @return mixed
*/
public static function createDriver($driver)
{
return static::canHandleNotification($driver) ? new static : null;
}
}