Laravel 5数据库不会播种

时间:2015-03-08 13:05:54

标签: php mysql laravel laravel-5

我有以下内容:

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

class CreateFinanceAccountsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('finance_accounts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->integer('created_by')->index();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('finance_accounts');
    }

}

播种者:

class FinanceAccountsTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('finance_accounts')->delete();

        App\Models\Finance\FinanceAccount::create([
            'name' => 'Default account',
            'created_by' => 1
        ]);
    }
}

通过以下方式调用:

class DatabaseSeeder extends Seeder
{

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();

        $this->call('UserRolesTableSeeder');
        $this->call('UserTableSeeder');
        $this->call('FinanceTransactionsTableSeeder');
        $this->call('FinanceAccountsTableSeeder');
        $this->call('CurrencyTableSeeder');
        $this->call('UserProfileTableSeeder');
    }
}

但是,表格创建正常,但没有插入数据。

我所有其他桌子的播种机工作得很好,不适合这个。

有谁知道为什么?


namespace App\Models\Finance;

use Illuminate\Database\Eloquent\Model;

class FinanceAccount extends Model {
    protected $table = 'finance_accounts';
}

0 个答案:

没有答案