Php 拉威尔播种误差
我试图在我的单向表中植入一些信息,但每次运行php artisan db:seed时,都会发生错误Php 拉威尔播种误差,php,laravel,laravel-4,Php,Laravel,Laravel 4,我试图在我的单向表中植入一些信息,但每次运行php artisan db:seed时,都会发生错误 {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me ssage":"Class 'Oneway' not found","file":"C:\\wamp\\www\\airlines\\app\\database \\seeds\\OnewayTableSeeder.php","line"
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Class 'Oneway' not found","file":"C:\\wamp\\www\\airlines\\app\\database
\\seeds\\OnewayTableSeeder.php","line":8}}
我尝试了作曲家转储自动加载,但仍然没有发生任何事情。这里有什么问题吗?
这是我的作曲还是我的密码
OnewayTableSeeder.php
<?php
class OnewayTableSeeder extends Seeder{
public function run()
{
DB::table('oneway')->delete();
Oneway::create(
array(
'destination-from'=>'Bacolod',
'destination-to'=>'Cebu',
'departure'=> \Carbon\Carbon::createFromDate(2014,10,01)->toDateTimeString(),
));
Oneway::create(
array(
'destination-from'=>'Tawi-Tawi',
'destination-to'=>'Cebu',
'departure'=> \Carbon\Carbon::createFromDate(2014,10,03)->toDateTimeString(),
));
Oneway::create(
array(
'destination-from'=>'Cebu',
'destination-to'=>'Dipolog',
'departure'=> \Carbon\Carbon::createFromDate(2014,10,16)->toDateTimeString(),
));
}
}
<?php
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
// $this->call('UserTableSeeder');
$this->call('OnewayTableSeeder');
}
}
还有其他人也有类似的迁移问题
这也许适合你
除此之外,请确保您有一个OneWay的模型,并确保播种器文件的名称与OnewayTableSeeder.php完全一致。此外,请尝试使用此包为数据库种子。我知道图书馆与你问的问题无关,但它很方便
此外,我个人尝试删除模型或播种机文件,它给了我一个不同于您的例外。我在任何地方都能找到的就是没有包含播种器文件,您应该运行composer dump autoload
或composer dump autoload
。请尝试这两种方法。文件名是onewaytableseder.php吗?谢谢您的快速回复,先生。是的,这是文件名。您是否为单向表创建了模型…如果没有创建模型,请再试一次。不,我没有创建模型。有必要做一个播种模型吗?我想是的。由于在种子文件OneWay::create()中进行的静态方法调用。如果没有单向模型类,则无法进行此类调用。