嗨,我有以下的播种机课程,我正试图播种。当我运行php artisan db:seed命令时,种子的唯一内容就是我几周前创建的上一个播种器类。我不知道我错过了什么。我也插入了SoftDeletes和Protected fillables。
这是我的播种机课程:
public function run()
{
DB::table('leave_type')->insert([
[
'leaveType' => 'Vacation Leave'
],
[
'leaveType' => 'Sick Leave'
],
[
'leaveType' => 'Afternoon Off'
],
[
'leaveType' => 'Special Leave'
],
[
'leaveType' => 'Study Leave'
],
]);
}
我的模特:
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class LeaveType extends Model
{
protected $fillable = ['leaveType'];
protected $table ="leave_type";
use SoftDeletes;
public $timestamps = true;
}
答案 0 :(得分:2)
将我的评论转换为答案;
composer dump-auto
{PROJECT}/database/seeds/DatabaseSeeder.php
中注册,如下所示:$这 - >呼叫(YourNewSeeder ::类);
然后您可以刷新数据库(回滚所有迁移,重新运行迁移)并使用此命令一次性运行播种器:
php artisan migrate:refresh --seed
或者只是像这样运行特定的播种机:
php artisan db:seed --class = YourNewSeeder