|
5 | 5 | class Email extends Entity |
6 | 6 | { |
7 | 7 | protected $table = 'outbox_emails'; |
8 | | - protected $dates = ['created_at', 'updated_at']; |
| 8 | + protected $dates = [ |
| 9 | + 'created_at', |
| 10 | + 'updated_at', |
| 11 | + ]; |
9 | 12 |
|
10 | | - /** |
11 | | - * Array of field names and the type of value to cast them as |
12 | | - * when they are accessed. |
13 | | - */ |
14 | | - protected $casts = [ |
15 | | - 'priority' => 'int', |
16 | | - 'sendMultipart' => 'boolean', |
17 | | - 'BCCBatchMode' => 'boolean', |
18 | | - 'BCCBatchSize' => 'int', |
19 | | - ]; |
| 13 | + /** |
| 14 | + * Array of field names and the type of value to cast them as |
| 15 | + * when they are accessed. |
| 16 | + */ |
| 17 | + protected $casts = [ |
| 18 | + 'priority' => 'int', |
| 19 | + 'sendMultipart' => 'boolean', |
| 20 | + 'BCCBatchMode' => 'boolean', |
| 21 | + 'BCCBatchSize' => 'int', |
| 22 | + ]; |
20 | 23 |
|
21 | | - /** |
22 | | - * Attachments cache |
23 | | - * |
24 | | - * @var array|null |
25 | | - */ |
26 | | - protected $attachments; |
| 24 | + /** |
| 25 | + * Attachments cache |
| 26 | + * |
| 27 | + * @var array|null |
| 28 | + */ |
| 29 | + protected $attachments; |
27 | 30 |
|
28 | | - /** |
29 | | - * Recipients cache |
30 | | - * |
31 | | - * @var array|null |
32 | | - */ |
33 | | - protected $recipients; |
| 31 | + /** |
| 32 | + * Recipients cache |
| 33 | + * |
| 34 | + * @var array|null |
| 35 | + */ |
| 36 | + protected $recipients; |
34 | 37 |
|
35 | | - /** |
36 | | - * Returns this email's attachments. |
37 | | - * |
38 | | - * @return array |
39 | | - */ |
40 | | - public function getAttachments(): array |
41 | | - { |
42 | | - return $this->getRelatedItems('attachment'); |
43 | | - } |
| 38 | + /** |
| 39 | + * Returns this email's attachments. |
| 40 | + * |
| 41 | + * @return array |
| 42 | + */ |
| 43 | + public function getAttachments(): array |
| 44 | + { |
| 45 | + return $this->getRelatedItems('attachment'); |
| 46 | + } |
44 | 47 |
|
45 | | - /** |
46 | | - * Returns this email's recipients. |
47 | | - * |
48 | | - * @return array |
49 | | - */ |
50 | | - public function getRecipients(): array |
51 | | - { |
52 | | - return $this->getRelatedItems('recipient'); |
53 | | - } |
| 48 | + /** |
| 49 | + * Returns this email's recipients. |
| 50 | + * |
| 51 | + * @return array |
| 52 | + */ |
| 53 | + public function getRecipients(): array |
| 54 | + { |
| 55 | + return $this->getRelatedItems('recipient'); |
| 56 | + } |
54 | 57 |
|
55 | | - /** |
56 | | - * Helper function to return attachments or recipients. |
57 | | - * |
58 | | - * @param string $target Object/table/model to request |
59 | | - * |
60 | | - * @return array |
61 | | - */ |
62 | | - protected function getRelatedItems(string $target): array |
63 | | - { |
64 | | - if (empty($this->id)) |
65 | | - { |
66 | | - throw new \RuntimeException('Object must be created before getting relations.'); |
67 | | - } |
| 58 | + /** |
| 59 | + * Helper function to return attachments or recipients. |
| 60 | + * |
| 61 | + * @param string $target Object/table/model to request |
| 62 | + * |
| 63 | + * @return array |
| 64 | + */ |
| 65 | + protected function getRelatedItems(string $target): array |
| 66 | + { |
| 67 | + if (empty($this->id)) |
| 68 | + { |
| 69 | + throw new \RuntimeException('Object must be created before getting relations.'); |
| 70 | + } |
68 | 71 |
|
69 | 72 | $property = $target . 's'; |
70 | 73 | $model = 'Tatter\Outbox\Models\\' . ucfirst($target) . 'Model'; |
71 | 74 |
|
72 | | - if (is_null($this->$property)) |
73 | | - { |
74 | | - $this->$property = model($model)->where('outbox_email_id', $this->id)->findAll(); |
75 | | - } |
| 75 | + if (is_null($this->$property)) |
| 76 | + { |
| 77 | + $this->$property = model($model)->where('outbox_email_id', $this->id)->findAll(); |
| 78 | + } |
76 | 79 |
|
77 | | - return $this->$property; |
78 | | - } |
| 80 | + return $this->$property; |
| 81 | + } |
79 | 82 | } |
0 commit comments