|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Gamer\Notifications\Organizer; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Bus\Queueable; |
|
6
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
7
|
|
|
use Illuminate\Queue\SerializesModels; |
|
8
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
|
9
|
|
|
use Illuminate\Notifications\Notification; |
|
10
|
|
|
use NotificationChannels\Zenvia\ZenviaChannel; |
|
11
|
|
|
use NotificationChannels\Zenvia\ZenviaMessage; |
|
12
|
|
|
use Log; |
|
13
|
|
|
use Gamer\Channels\SmsChannel; |
|
14
|
|
|
use Gamer\Channels\Messages\SmsMessage; |
|
15
|
|
|
|
|
16
|
|
|
class ServiceDied extends Notification implements ShouldQueue |
|
17
|
|
|
{ |
|
18
|
|
|
use Queueable; |
|
19
|
|
|
|
|
20
|
|
|
protected $_business = null; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Create a new notification instance. |
|
24
|
|
|
* |
|
25
|
|
|
* @param $businessToken |
|
26
|
|
|
* @return void |
|
|
|
|
|
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct($business) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->_business = $business; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Get the notification's delivery channels. |
|
35
|
|
|
* |
|
36
|
|
|
* @param mixed $notifiable |
|
37
|
|
|
* @return array |
|
38
|
|
|
*/ |
|
39
|
|
|
public function via($notifiable) |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
return [SmsChannel::class]; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Get the mail representation of the notification. |
|
46
|
|
|
* |
|
47
|
|
|
* @param mixed $notifiable |
|
48
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
49
|
|
|
*/ |
|
50
|
|
|
public function toSms($notifiable) |
|
51
|
|
|
{ |
|
52
|
|
|
$number = \App\Sitec\Filter::phone($notifiable->telefone_celular); |
|
53
|
|
|
|
|
54
|
|
|
$nomeProdutora = ''; |
|
55
|
|
|
if (!empty($this->_business) && isset($this->_business->nome)) { |
|
56
|
|
|
$nomeProdutora = $this->_business->nome; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$message = $notifiable->token_sms ." Token SMS ". $nomeProdutora .". Insira o token para validar sua conta."; |
|
60
|
|
|
Log::debug( |
|
61
|
|
|
'[Notification] Esqueci minha Senha > Mensagem: '.$message. |
|
62
|
|
|
' Numero: '.$number |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
return SmsMessage::create() |
|
66
|
|
|
->from('Passepague') // optional |
|
67
|
|
|
->to($number) // your user phone |
|
68
|
|
|
->content($message); |
|
69
|
|
|
// ->id('your-sms-id'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get the array representation of the notification. |
|
74
|
|
|
* |
|
75
|
|
|
* @param mixed $notifiable |
|
76
|
|
|
* @return array |
|
77
|
|
|
*/ |
|
78
|
|
|
public function toArray($notifiable) |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
return [ |
|
81
|
|
|
// |
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
} |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.