1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Notifications; |
4
|
|
|
|
5
|
|
|
use App\Tournament; |
6
|
|
|
use App\User; |
7
|
|
|
use Illuminate\Bus\Queueable; |
8
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
9
|
|
|
use Illuminate\Notifications\Notification; |
10
|
|
|
use Illuminate\Support\Facades\URL; |
11
|
|
|
|
12
|
|
|
class InviteCompetitor extends Notification |
13
|
|
|
{ |
14
|
|
|
use Queueable; |
15
|
|
|
|
16
|
|
|
protected $user, $tournament, $code, $category; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Create a new notification instance. |
20
|
|
|
* |
21
|
|
|
* @param User $user |
22
|
|
|
* @param Tournament $tournament |
23
|
|
|
* @param $code |
24
|
|
|
* @param null $category |
|
|
|
|
25
|
|
|
*/ |
26
|
1 |
|
public function __construct(User $user, Tournament $tournament, $code, $category = null) |
27
|
|
|
{ |
28
|
1 |
|
$this->user = $user; |
29
|
1 |
|
$this->tournament = $tournament; |
30
|
1 |
|
$this->code = $code; |
31
|
1 |
|
$this->category = $category; |
32
|
1 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get the notification's delivery channels. |
36
|
|
|
* |
37
|
|
|
* @param mixed $notifiable |
38
|
|
|
* @return array |
39
|
|
|
*/ |
40
|
1 |
|
public function via($notifiable) |
|
|
|
|
41
|
|
|
{ |
42
|
1 |
|
return ['mail']; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the mail representation of the notification. |
47
|
|
|
* |
48
|
|
|
* @param mixed $notifiable |
49
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
50
|
|
|
*/ |
51
|
1 |
|
public function toMail($notifiable) |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
|
54
|
1 |
|
$subject = trans('mail.invite_to_tournament') . ": " . $this->tournament->name; |
55
|
1 |
|
$message = (new MailMessage) |
56
|
1 |
|
->subject($subject) |
57
|
1 |
|
->greeting(trans('mail.dear_kenshi')) |
58
|
1 |
|
->line(trans('mail.you_are_invited_to_tournament') . ":" . $this->tournament->name); |
59
|
|
|
|
60
|
1 |
|
if ($this->tournament->venue_id != null) { |
61
|
|
|
$message |
62
|
|
|
->line("<strong>" . trans('core.venue') . ': </strong>' . $this->tournament->venue_name) |
|
|
|
|
63
|
|
|
->line("<strong>" . trans('core.address') . ': </strong>' . $this->tournament->venue->address); |
64
|
|
|
} |
65
|
|
|
$message |
66
|
1 |
|
->line(trans("<strong>" . trans('core.eventDateIni') . ': </strong>' . $this->tournament->dateIni)) |
67
|
1 |
|
->line(trans("<strong>" . trans('core.eventDateFin') . ': </strong>' . $this->tournament->dateFin)); |
68
|
|
|
|
69
|
1 |
|
if ($this->tournament->cost != null) { |
|
|
|
|
70
|
|
|
$message->line("<strong>" . trans('core.cost') . ': </strong>' . $this->tournament->cost); |
71
|
|
|
} |
72
|
|
|
|
73
|
1 |
|
if ($this->tournament->registerDateLimit != null && $this->tournament->registerDateLimit != '0000-00-00') { |
74
|
1 |
|
$message->line("<strong>" . trans('core.limitDateRegistration') . ': </strong>' . $this->tournament->registerDateLimit); |
75
|
|
|
} |
76
|
1 |
|
if (isset($this->category)) { |
77
|
|
|
$message->line("<strong>" . trans('mail.you_have_been_preregistered') . "</strong>") |
78
|
|
|
->line('- ' . $this->category); |
79
|
|
|
} else { |
80
|
1 |
|
$message->action(trans('mail.confirm_registration'), |
81
|
1 |
|
URL::action('ChampionshipController@create', [ |
82
|
1 |
|
'tournamentSlug' => $this->tournament->slug, |
83
|
1 |
|
'token' => $this->code |
84
|
|
|
])); |
85
|
|
|
} |
86
|
1 |
|
if ($this->user->password != null) { |
87
|
|
|
$message->line(trans('mail.your_connection_data') . ":") |
88
|
|
|
->line(trans('core.username') . ":" . $this->user->email) |
89
|
|
|
->line(trans('core.password') . ":" . $this->user->clearPassword); |
90
|
|
|
} |
91
|
|
|
|
92
|
1 |
|
$message->line(trans('core.thanks')); |
93
|
|
|
|
94
|
1 |
|
return $message; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Get the array representation of the notification. |
100
|
|
|
* |
101
|
|
|
* @param mixed $notifiable |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
public function toArray($notifiable) |
|
|
|
|
105
|
|
|
{ |
106
|
|
|
return [ |
107
|
|
|
// |
108
|
|
|
]; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|