Example #1
0
 /**
  * Set model attributes.
  *
  * @param $attributesValues
  */
 public function setAttributesValues($attributesValues)
 {
     foreach ($this->attributes as $key => $rules) {
         if (array_key_exists($key, $attributesValues)) {
             if (array_key_exists('maxLength', $rules) && Model::checkMaxLength($attributesValues[$key], $rules['maxLength'])) {
                 Router::ErrorResponse('Field ' . $key . ' max length ' . $rules[maxLength] . '.');
                 die;
             }
             $this->attributesValues[$key] = $attributesValues[$key];
         } elseif (array_key_exists('nullable', $rules) && $rules['nullable'] == false) {
             Router::ErrorResponse('Field ' . $key . ' is required.');
             die;
         }
     }
 }