Esempio n. 1
0
 /**
  * toArray. Modules may define a custom toArray method.
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     // Typecast every known field with it's respective data-type.
     // Integer, float and boolean fields may vary accourding to the
     // database engine
     if (isset($this->schema['attributes'])) {
         foreach ($this->schema['attributes'] as $attribute) {
             @settype($array[$attribute['name']], $attribute['type']);
         }
     }
     $observer = static::getObserver($this->getTable());
     if ($observer) {
         if (method_exists($observer, 'toArray')) {
             return $observer->toArray($this, $array);
         }
     }
     return $array;
 }