1 | <?php |
||
2 | |||
3 | namespace MedianetDev\CloudMessage\Jobs; |
||
4 | |||
5 | use Illuminate\Bus\Queueable; |
||
6 | use Illuminate\Contracts\Queue\ShouldQueue; |
||
7 | use Illuminate\Foundation\Bus\Dispatchable; |
||
8 | use Illuminate\Queue\InteractsWithQueue; |
||
9 | use Illuminate\Queue\SerializesModels; |
||
10 | use MedianetDev\CloudMessage\Drivers\Notification; |
||
11 | |||
12 | class MultiTokensJob implements ShouldQueue |
||
13 | { |
||
14 | use Dispatchable; |
||
15 | use InteractsWithQueue; |
||
16 | use Queueable; |
||
17 | use SerializesModels; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
18 | use Notification; |
||
19 | |||
20 | protected $tokens; |
||
21 | protected $message; |
||
22 | protected $url; |
||
23 | protected $headers; |
||
24 | |||
25 | public function __construct($tokens, $message, $url, $headers) |
||
26 | { |
||
27 | $this->tokens = $tokens; |
||
28 | $this->message = $message; |
||
29 | $this->url = $url; |
||
30 | $this->headers = $headers; |
||
31 | } |
||
32 | |||
33 | public function handle() |
||
34 | { |
||
35 | foreach ($this->tokens as $mobileId) { |
||
36 | self::request($this->url, json_encode(['message' => [ |
||
37 | 'token' => $mobileId, |
||
38 | 'data' => $this->message, |
||
39 | 'notification' => [ |
||
40 | 'title' => $this->message['title'], |
||
41 | 'body' => $this->message['body'], |
||
42 | ], |
||
43 | ]]), $this->headers); |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 |