Skip to content

Commit

Permalink
Pass in false to Table creator to not generate any columns
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrock committed Apr 16, 2015
1 parent 57ac297 commit 6dbff8f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/Table.php
Expand Up @@ -20,9 +20,9 @@ public function __construct($models = [], $columns = [])
{
$this->setModels($models);

if(!$columns)
if(!$columns && $columns !== FALSE)
{
// Columns were not passed; generate them
// Columns were not passed and were not prevented from auto-generation; generate them
$columns = $this->getFieldsFromModels($models);
}

Expand Down Expand Up @@ -88,22 +88,25 @@ protected function addColumns($columns)
{
$model = $this->models->first();

foreach($columns as $key => $field)
if($columns)
{
if(is_numeric($key))
foreach($columns as $key => $field)
{
// Simple non-keyed array passed.
$new_column = Column::create($field);
if(is_numeric($key))
{
// Simple non-keyed array passed.
$new_column = Column::create($field);
}
else
{
// Key also matters, apparently
$new_column = Column::create($key, $field);
}

$new_column->setOptionsFromModel($model);

$this->columns[] = $new_column;
}
else
{
// Key also matters, apparently
$new_column = Column::create($key, $field);
}

$new_column->setOptionsFromModel($model);

$this->columns[] = $new_column;
}
}

Expand Down

0 comments on commit 6dbff8f

Please sign in to comment.