Exemplo n.º 1
0
 /**
  * addField
  *
  * @param string $method
  * @param string $field
  * @param string $data
  * @throws ModelException
  * @return Fields
  */
 private function addField($method, $field, $data)
 {
     $method = strtolower($method);
     if (!$this->fields->has($method)) {
         $this->fields->add($method, new Collection());
     }
     if (!is_array($this->dataBind)) {
         $this->dataBind = [];
     }
     $bind = ['field' => $field, 'type' => $method, 'size' => isset($data['size']) ? $data['size'] : 0, 'auto' => false];
     if ($this->getAutoincrement() !== false) {
         if ($this->getAutoincrement()->field == $field) {
             $bind['auto'] = true;
         }
     }
     if ($method == 'enum') {
         $bind['default'] = $data['default'] != null ? $data['default'] : $data['value'][0];
     }
     $this->dataBind[$field] = $bind;
     if ($this->fields->get($method)->has($field)) {
         return $this;
     }
     // default index are at false
     $data['primary'] = false;
     $data['unique'] = false;
     $data['indexe'] = false;
     $this->fields->get($method)->add($field, $data);
     $this->lastField = (object) ['method' => $method, 'field' => $field];
     return $this;
 }
Exemplo n.º 2
0
 /**
  * off supprime un event enregistre
  *
  * @param string $event
  * @param Callable $cb
  */
 public static function off($event, $cb = null)
 {
     if (static::$events->has($event)) {
         static::$events->delete($event);
         Util::launchCallback($cb);
     }
 }
Exemplo n.º 3
0
 /**
  * retourne une instance de collection
  *
  * @param array $data [optional]
  * @return \Bow\Support\Collection
  */
 function collect(array $data = [])
 {
     $col = new Collection();
     foreach ($data as $key => $param) {
         $col->add($key, $param);
     }
     return $col;
 }
Exemplo n.º 4
0
 /**
  * toCollection, retourne les données de la DB sous en instance de Collection
  *
  * @return Collection
  */
 public function toCollection()
 {
     $data = $this->get();
     $coll = new Collection();
     foreach ($data as $key => $value) {
         $coll->add($key, $value);
     }
     return $coll;
 }