'required|int', 'support_code' => 'required|int', 'label_type_support' => 'required|string|min:2|max:255', 'order_date' => 'required|date', 'code_unique' => 'required|string', 'code_on_pack' => 'sometimes|string' ]; public function __construct(array $properties = []) { parent::__construct(); $this->fill($properties); return $this; } /** * Set prop * * @param string $field * @param mixed $value * @throws TypeError if the field has an incorrect value * @return mixed|null The input value or null is this prop does not exists */ public function __set(string $field, $value) { $out = parent::__set($field, $value); if (in_array($field, $this->modelFields)) { $this->updatedValues[$field] = (\is_object($value) and get_class($value) === ArcadiaOrderType::class) ? $value->value : $value; $this->setRawProperty($this, $field, $this->updatedValues[$field]); } return $out; } // PUBLIC METHODS /** * Send The actual mail * * @return boolean true if succeeded * @throws \LDC\LDCCRM\Exceptions\CrmException * if an error occurs on server side or on getting response * @throws \LDC\LDCCRM\Exceptions\ApiErrorException * If any error or \LDC\LDCCRM\Enums\ApiError occurs */ public function send(Customer $customer): bool { // validate customer hashcode $refClass = new ReflectionClass(\get_class($customer)); $refMeth = $refClass->getMethod('validateValue'); $refMeth->setAccessible(true); $refMeth->invokeArgs($customer, ['hashcode', $customer->hashcode]); // Send mail $data = $this->validateAllValues(); static::setUpApiInterface(); // set apiInterface $request = Utils::getResquest('apiV2.arcadia.outgoingMailGame', [ 'customer' => $customer->hashcode ], $data); $response = static::$apiInterface->call($request); if ($status = $response->status->equals(ApiStatus::OK())) { $this->updatedValues = []; } $this->isNew = !$status; return $status; } }