我试图在我的项目中播种数据库。当我这样做时,仅插入“标题”和“帖子”字段,“ Created_at”和“ Updated_at”未更改,并显示为0000-00-00 00:00:00。我也尝试过time()。它可以在“ php artisan tink
”中正常工作,但数据库中的任何结果都不会更改。
<?php
class QuestionsTableSeeder extends Seeder {
public function run()
{
DB::table('questions')->truncate();
$questions = array(
'title' => 'Simple Question Title',
'post' => 'Lorem ipsum dolor',
'created_at' => time()
);
// Uncomment the below to run the seeder
DB::table('questions')->insert($questions);
}
}
您可以使用new DateTime()
!希望这会帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句