Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
MessageEmail
92.86% covered (success)
92.86%
13 / 14
66.67% covered (warning)
66.67%
2 / 3
3.00
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 build
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 attachments
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Mail;
4
5use Illuminate\Bus\Queueable;
6use Illuminate\Mail\Mailable;
7use Illuminate\Queue\SerializesModels;
8
9class MessageEmail extends Mailable
10{
11    use Queueable, SerializesModels;
12
13    private string $email_name;
14
15    private ?string $email_address;
16
17    private string $email_subject;
18
19    private string $email_body;
20
21    /**
22     * Create a new message instance.
23     *
24     * @return void
25     */
26    public function __construct($data)
27    {
28        $this->email_name    = $data['name'];
29        $this->email_address = $data['email'];
30        $this->email_subject = $data['subject'] ?? '';
31        $this->email_body    = $data['content'];
32    }
33
34    /**
35     * Get the message content definition.
36     *
37     * @return MessageEmail
38     */
39    public function build(): MessageEmail
40    {
41        return $this->from(env('MAIL_USERNAME'), env('MAIL_FROM_NAME'))
42            ->subject('New message received')
43            ->view('mail.message')
44            ->with([
45                'email_name'    => $this->email_name,
46                'email_address' => $this->email_address,
47                'email_subject' => $this->email_subject,
48                'email_body'    => $this->email_body
49            ]);
50    }
51
52    /**
53     * Get the attachments for the message.
54     *
55     * @return array
56     */
57    public function attachments(): array
58    {
59        return [];
60    }
61}