create-prisma-php-app 1.16.1 → 1.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,8 @@ class Mailer
37
37
  * @param string $body The HTML body of the email.
38
38
  * @param string $name (optional) The name of the recipient.
39
39
  * @param string $altBody (optional) The plain text alternative body of the email.
40
+ * @param string|array $addCC (optional) Additional email addresses to send a carbon copy (CC) to.
41
+ * @param string|array $addBCC (optional) Additional email addresses to send a blind carbon copy (BCC) to.
40
42
  *
41
43
  * @return bool Returns true if the email is sent successfully, false otherwise.
42
44
  *
@@ -49,9 +51,11 @@ class Mailer
49
51
  * $body = '<h1>Example Email</h1><p>This is the HTML body of the email.</p>';
50
52
  * $name = 'John Doe';
51
53
  * $altBody = 'This is the plain text alternative body of the email.';
54
+ * $addCC = ['cc1@example.com', 'cc2@example.com'];
55
+ * $addBCC = 'bcc@example.com';
52
56
  *
53
57
  * try {
54
- * $result = $mailer->send($to, $subject, $body, $name, $altBody);
58
+ * $result = $mailer->send($to, $subject, $body, $name, $altBody, $addCC, $addBCC);
55
59
  * if ($result) {
56
60
  * echo 'Email sent successfully.';
57
61
  * } else {
@@ -61,21 +65,78 @@ class Mailer
61
65
  * echo 'An error occurred: ' . $e->getMessage();
62
66
  * }
63
67
  */
64
- public function send(string $to, string $subject, string $body, string $name = '', string $altBody = ''): bool
65
- {
68
+ public function send(
69
+ string $to,
70
+ string $subject,
71
+ string $body,
72
+ string $name = '',
73
+ string $altBody = '',
74
+ string|array $addCC = [],
75
+ string|array $addBCC = []
76
+ ): bool {
66
77
  try {
67
- Validator::string($to);
68
- Validator::string($subject);
69
- Validator::string($body);
70
- Validator::string($name);
71
- Validator::string($altBody);
78
+ // Validate the main recipient email
79
+ $to = Validator::email($to);
80
+ if (!$to) {
81
+ throw new \Exception('Invalid email address for the main recipient');
82
+ }
83
+
84
+ // Validate and sanitize other inputs
85
+ $subject = Validator::string($subject);
86
+ $body = Validator::string($body);
87
+ $name = Validator::string($name);
88
+ $altBody = Validator::string($altBody);
89
+
90
+ // Handle CC recipients
91
+ if (!empty($addCC)) {
92
+ if (is_array($addCC)) {
93
+ foreach ($addCC as $cc) {
94
+ $cc = Validator::email($cc);
95
+ if ($cc) {
96
+ $this->mail->addCC($cc);
97
+ } else {
98
+ throw new \Exception('Invalid email address in CC');
99
+ }
100
+ }
101
+ } else {
102
+ $cc = Validator::email($addCC);
103
+ if ($cc) {
104
+ $this->mail->addCC($cc);
105
+ } else {
106
+ throw new \Exception('Invalid email address in CC');
107
+ }
108
+ }
109
+ }
110
+
111
+ // Handle BCC recipients
112
+ if (!empty($addBCC)) {
113
+ if (is_array($addBCC)) {
114
+ foreach ($addBCC as $bcc) {
115
+ $bcc = Validator::email($bcc);
116
+ if ($bcc) {
117
+ $this->mail->addBCC($bcc);
118
+ } else {
119
+ throw new \Exception('Invalid email address in BCC');
120
+ }
121
+ }
122
+ } else {
123
+ $bcc = Validator::email($addBCC);
124
+ if ($bcc) {
125
+ $this->mail->addBCC($bcc);
126
+ } else {
127
+ throw new \Exception('Invalid email address in BCC');
128
+ }
129
+ }
130
+ }
72
131
 
132
+ // Set the main recipient and other email properties
73
133
  $this->mail->addAddress($to, $name);
74
134
  $this->mail->isHTML(true);
75
135
  $this->mail->Subject = $subject;
76
136
  $this->mail->Body = $body;
77
137
  $this->mail->AltBody = $altBody;
78
138
 
139
+ // Send the email
79
140
  return $this->mail->send();
80
141
  } catch (\Exception $e) {
81
142
  throw new \Exception($e->getMessage());
@@ -212,6 +212,11 @@ abstract class Utility
212
212
  $groupedConditions = [];
213
213
  if ($key === 'NOT') {
214
214
  self::processNotCondition($value, $groupedConditions, $bindings, $dbType, $prefix . $key . '_', $level);
215
+ if (!empty($groupedConditions)) {
216
+ $conditionGroup = '(' . implode(" $key ", $groupedConditions) . ')';
217
+ $conditionGroup = 'NOT ' . $conditionGroup;
218
+ $sqlConditions[] = $conditionGroup;
219
+ }
215
220
  } else {
216
221
  foreach ($value as $conditionKey => $subCondition) {
217
222
  if (is_numeric($conditionKey)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.16.1",
3
+ "version": "1.16.3",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",