类扩展 Eloquent 的构造函数
我刚刚开始一个新的网站,我想利用Eloquent。在为数据库设定种子的过程中,我注意到,如果我在模型上包含任何类型的扩展雄辩的构造函数,我都会添加空行。例如,运行此播种机:
<?php
class TeamTableSeeder extends Seeder {
public function run()
{
DB::table('tm_team')->delete();
Team::create(array(
'city' => 'Minneapolis',
'state' => 'MN',
'country' => 'USA',
'name' => 'Twins'
)
);
Team::create(array(
'city' => 'Detroit',
'state' => 'MI',
'country' => 'USA',
'name' => 'Tigers'
)
);
}
}
以此作为我的团队类:
<?php
class Team extends Eloquent {
protected $table = 'tm_team';
protected $primaryKey = 'team_id';
public function Team(){
// null
}
}
产生以下结果:
team_id | city | state | country | name | created_at | updated_at | deleted_at
1 | | | | | 2013-06-02 00:29:31 | 2013-06-02 00:29:31 | NULL
2 | | | | | 2013-06-02 00:29:31 | 2013-06-02 00:29:31 | NULL
只需将构造函数全部删除即可使播种机按预期工作。我到底在构造函数上做错了什么?