コード例 #1
0
ファイル: rowdata.php プロジェクト: SerdarSanri/laravel-squi
 /**
  * Add column values to the row
  * Can be either an array of string cell contents
  * or the string contents as keys and array of attributes
  * as values, or a combination of the above.
  */
 public function values($values)
 {
     foreach ($values as $key => $val) {
         $col = new Table_Column();
         $attr = is_array($val) ? $val : array();
         if (is_int($key) && is_array($val)) {
             $col->value(isset($val['value']) ? $val['value'] : '');
             $col->attr(isset($val['attr']) ? $val['attr'] : array());
         } else {
             $col->value($val);
         }
         $this->columns[] = $col;
     }
 }
コード例 #2
0
ファイル: table.php プロジェクト: SerdarSanri/laravel-squi
 /**
  * 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;
 }