【发布时间】:2013-05-03 11:33:02
【问题描述】:
在 Laravel 4 中有一个 dateTime() 函数可以帮助创建这些列。但是在 Laravel 3 的Schema\Table 中,我只看到了一个date() 函数,即:
public function date($name)
{
return $this->column(__FUNCTION__, compact('name'));
}
看起来它只是创建了一个 DATE 列。但是,我也看到了这个神奇的功能:
public function __call($method, $parameters)
{
if (isset(static::$macros[$method]))
{
array_unshift($parameters, $this);
return call_user_func_array(static::$macros[$method], $parameters);
}
throw new \Exception("Method [$method] does not exist.");
}
有没有办法使用这个函数创建一个 DATETIME 列?我该怎么做?在文档中找不到此信息。
【问题讨论】:
-
不是 $table->timestamp('column') 你在找什么吗?检查laravel.com/docs/database/schema。
-
不,不是时间戳,我需要一个 DATETIME,但最终的答案是“doh”时刻。我会回答我自己的问题...