laravel 5.2 种子无效

laravel 5.2 seed not working

迁移

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePlayersTable extends Migration
{
    public function up()
    {
        Schema::create('players', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username');
            $table->boolean('status')->default(1); // True
            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down()
    {
        Schema::drop('players');
    }
}

型号

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Player extends Model
{
    use SoftDeletes;

    protected $table = 'players';
    protected $fillable = ['id', 'username', 'status'];
    protected $dates = ['deleted_at'];
}

播种机

<?php

use Illuminate\Database\Seeder;
use Carbon\Carbon as Carbon;

class PlayersSeeder extends Seeder
{
    public function run()
    {
        DB::table('players')->insert([
            [
                'id' => 1,
                'username' => 'EKBD0223',
                'status' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
                'deleted_at' => NULL,
            ]
        ]);
    }
}

为什么在 运行 php artisan db:seed 时它没有抛出错误,但是当我检查数据库时,来自播种机的数据没有插入到 table? 我错过了吗?因为我没有在我的代码中看到错误:(

您必须将播种机添加到主播种机:DatabaseSeeder.php

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(PlayersSeeder::class);
    }
}