Use getDates() for type check

Fixes #63
This commit is contained in:
Barry vd. Heuvel
2014-02-21 12:00:54 +01:00
parent 512574de9a
commit 7b47af171d
@@ -203,14 +203,18 @@ class ModelsCommand extends Command {
if($columns){ if($columns){
foreach ($columns as $column) { foreach ($columns as $column) {
$name = $column->getName(); $name = $column->getName();
if(in_array($name, $model->getDates())){
$type = '\Carbon\Carbon';
}else{
$type = $column->getType()->getName(); $type = $column->getType()->getName();
switch($type){ switch($type){
case 'string': case 'string':
case 'text': case 'text':
case 'date': case 'date':
case 'time': case 'time':
case 'guid': case 'guid':
case 'datetimetz':
case 'datetime':
$type = 'string'; $type = 'string';
break; break;
case 'integer': case 'integer':
@@ -225,14 +229,13 @@ class ModelsCommand extends Command {
case 'boolean': case 'boolean':
$type = 'boolean'; $type = 'boolean';
break; break;
case 'datetimetz': //String or DateTime, depending on $dates
case 'datetime':
$type = '\Carbon\Carbon';
break;
default: default:
$type = 'mixed'; $type = 'mixed';
break; break;
} }
}
$this->setProperty($name, $type, true, true); $this->setProperty($name, $type, true, true);
$this->setMethod(Str::camel("where_".$name), '\\'.get_class($model), array('$value')); $this->setMethod(Str::camel("where_".$name), '\\'.get_class($model), array('$value'));
} }