我所做的一切都是按书本进行的:
安装了新的 Laravel 5.3.9 应用程序(我所有的非新应用程序都会产生相同的错误)
run php artisan make:auth
-
为新表创建迁移
`php artisan make:migration create_quotations_table --create=quotations
Schema::create('quotations', function (Blueprint $table) {
$table->increments('id');
$table->string('text');
// my problem persists even with the below two columns commented out
$table->integer('creator_id')->unsigned()->index('creator_id');
$table->integer('updater_id')->unsigned()->index('updater_id');
$table->softDeletes();
$table->timestamps();
});
然后我跑php artisan migrate
然后我定义一个新的种子php artisan make:seeder QuotationsTableSeeder
在我添加简单的插入后,文件的完整内容:
<?php
use Illuminate\Database\Seeder;
class QuotationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('quotations')->insert([
'text' => str_random(10),
]);
}
}
- 然后我跑
php artisan db:seed
problem
它根本不起作用。没有提供反馈,日志文件中没有错误。
探针在我的本地环境(Win7、最新的 WAMP 服务器)中持续存在
以及我的由 Ubuntu 16.04 提供支持的 Digital Ocean VPS。
我在几个单独的应用程序中执行了上述所有步骤 - 但没有结果。也在 Laragon 2.0.5 服务器下。
我尝试过什么
php artisan optimize
正如这里所建议的 http://laravel.io/forum/04-22-2015-cant-seed-db-in-laravel-5.
composer dump-autoload
i php artisan clear-compiled
也没有带来任何结果
我还尝试按照官方文档示例进行播种 - 失败了。
I added use DB;
到种子文件 - 仍然没有结果。
to do
帮助!!!他们怎么不工作呢?
你在叫你的播种者在里面吗?DatabaseSeeder
班级?这边走:
数据库/seeds/DatabaseSeeder.php
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(QuotationTableSeeder::class);
}
}
或者,添加--class
使用时的选项php artisan db:seed
命令,这样:
php artisan db:seed --class="QuotationTableSeeder"
创建或删除播种器后,不要忘记运行以下命令:
composer dump-autoload
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)