|
|
@@ -12,6 +12,7 @@ use Carbon\CarbonImmutable;
|
|
|
* @property string $postal_code
|
|
|
* @property string $country
|
|
|
* @property string $email
|
|
|
+ * @property string $cc_email_json
|
|
|
* @property string $phone
|
|
|
* @property string $invoice_contact_name
|
|
|
* @property bool $email_after_test
|
|
|
@@ -29,7 +30,7 @@ class Customer extends Model {
|
|
|
protected static $table = "customer";
|
|
|
protected static $id_field = "id";
|
|
|
protected static $fillable_fields = ["name", "address_1", "address_2",
|
|
|
- "city", "county", "postal_code", "country", "email", "phone",
|
|
|
+ "city", "county", "postal_code", "country", "email", "cc_email_json", "phone",
|
|
|
"invoice_contact_name",
|
|
|
"email_after_test", "email_locations_after_test",
|
|
|
"internal_id_field_name", "region_field_name", "area_manager_field_name",
|
|
|
@@ -298,4 +299,20 @@ class Customer extends Model {
|
|
|
return $this->getConfig()->seniorGamingManagerLabels[$index] ?? $default_labels[$index];
|
|
|
}
|
|
|
|
|
|
+ public function getCcEmailAddresses(): array {
|
|
|
+ $addresses = json_decode($this->cc_email_json);
|
|
|
+ return is_array($addresses) ? $addresses : [];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setCcEmailAddresses(array $addresses): void {
|
|
|
+ foreach($addresses as $address) {
|
|
|
+ $valid = filter_var($address, FILTER_VALIDATE_EMAIL);
|
|
|
+ if(!$valid) {
|
|
|
+ throw new RuntimeException(__("%s is not a valid email address.", $address));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->cc_email_json = json_encode($addresses);
|
|
|
+ }
|
|
|
+
|
|
|
}
|