2019-11-20 23:16:01 +08:00
|
|
|
<?php
|
|
|
|
|
2020-09-04 00:50:42 +08:00
|
|
|
namespace App\Contracts;
|
2019-11-20 23:16:01 +08:00
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2020-09-04 00:50:42 +08:00
|
|
|
class Notification extends \Illuminate\Notifications\Notification implements ShouldQueue
|
2019-11-20 23:16:01 +08:00
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
public $channels = [];
|
2020-09-04 00:50:42 +08:00
|
|
|
public $requires_opt_in = false;
|
2019-11-20 23:16:01 +08:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
// Look in the notifications.channels config and see where this particular
|
|
|
|
// notification can go. Map it to $channels
|
2020-08-12 05:48:51 +08:00
|
|
|
$klass = static::class;
|
2019-11-20 23:16:01 +08:00
|
|
|
$notif_config = config('notifications.channels', []);
|
|
|
|
if (!array_key_exists($klass, $notif_config)) {
|
2020-05-09 23:31:25 +08:00
|
|
|
Log::error('Notification type '.$klass.' missing from notifications config, defaulting to mail');
|
2019-11-20 23:16:01 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->channels = $notif_config[$klass];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the notification's delivery channels.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function via($notifiable)
|
|
|
|
{
|
|
|
|
return $this->channels;
|
|
|
|
}
|
|
|
|
}
|