예제 #1
0
 /**
  * Define a column using Schema-style callback
  */
 public function column($name, $callback = null)
 {
     $col = Table_Column::make($this);
     // column(Table_Column)
     if (is_a($name, 'Squi\\Table_Column')) {
         $col = $name;
         $col->table = $this;
     } elseif (is_callable($name) && is_null($callback)) {
         call_user_func($name, $col, $this);
     } elseif (is_string($name) && is_null($callback)) {
         // Shortcut that converts a single column descriptor
         // into a label (captitalizing and converting underscores)
         // and assuming that string is the row property/key from
         // which to grab the column value.
         $col->name(ucwords(str_replace('_', ' ', $name)))->value($name);
     } elseif (is_string($name) && is_string($callback)) {
         $col->name($name)->value($callback);
     } elseif (is_string($name) && is_callable($callback)) {
         $col->name($name)->value($callback);
     }
     return $this->columns[] = $col;
 }