|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Mail; |
|
4
|
|
|
|
|
5
|
|
|
use App\Loan; |
|
6
|
|
|
use Illuminate\Bus\Queueable; |
|
7
|
|
|
use Illuminate\Mail\Mailable; |
|
8
|
|
|
use Illuminate\Queue\SerializesModels; |
|
9
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
10
|
|
|
|
|
11
|
|
|
class ManualReminderEmail extends Mailable |
|
12
|
|
|
{ |
|
13
|
|
|
use Queueable, SerializesModels; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Create a new message instance. |
|
17
|
|
|
* |
|
18
|
|
|
* @param Loan $loan |
|
19
|
|
|
* @param $subject |
|
20
|
|
|
* @param $body |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct(Loan $loan, $subject, $body) |
|
23
|
|
|
{ |
|
24
|
|
|
$sender = $loan->library; |
|
25
|
|
|
$lang = $loan->user->lang; |
|
26
|
|
|
|
|
27
|
|
|
switch ($lang) { |
|
28
|
|
|
case 'eng': |
|
29
|
|
|
$sender_name = $sender->name_eng; |
|
30
|
|
|
break; |
|
31
|
|
|
default: |
|
32
|
|
|
$sender_name = $sender->name; |
|
33
|
|
|
break; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$this->data = [ |
|
|
|
|
|
|
37
|
|
|
'sender_name' => $sender_name, |
|
38
|
|
|
'sender_mail' => $sender->email, |
|
39
|
|
|
'receiver_name' => $loan->user->firstname . ' ' . $loan->user->lastname, |
|
40
|
|
|
'receiver_mail' => $loan->user->email, |
|
41
|
|
|
'subject' => (string) $subject, |
|
42
|
|
|
'body' => (string) $body, |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function toArray() |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->data; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Build the message. |
|
53
|
|
|
* |
|
54
|
|
|
* @return $this |
|
55
|
|
|
*/ |
|
56
|
|
|
public function build() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this |
|
59
|
|
|
->from($this->data['sender_mail'], $this->data['sender_name']) |
|
60
|
|
|
->to($this->data['receiver_mail'], $this->data['receiver_name']) |
|
61
|
|
|
->subject($this->data['subject']) |
|
62
|
|
|
->text('emails.generic') |
|
63
|
|
|
->with([ |
|
64
|
|
|
'content' => $this->data['body'], |
|
65
|
|
|
]); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|