当我运行:php artisan db:seed我收到以下错误消息:反射异常,类ServiceTableSeeder dos不存在。 我试图运行:composer dump-autoload,现在我收到此错误消息:
[Symfony的\元器件\调试\异常\ FatalErrorException] 未找到“播种者”类
我该如何解决?
这是我的databaseSeeder:
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call(UserTableSeeder::class);
$this->call('ServiceTableSeeder');
}
}
这是我的ServiceTableSeeder:
<?php
class ServiceTableSeeder extends Seeder {
public function run() {
DB::table('services')->delete();
$services = array (
array(
'title' => 'kdcsv',
'description' => 'kasdks',
'long_description' => 'asjdkas asjdsjkj sjdk',
'image_thumb' => 'jask',
'image' => 'aksjdksaj'
),
array(
'title' => 'blabla',
'description' => 'kasdks',
'long_description' => 'asjdkas asjdsjkj sjdk',
'image_thumb' => 'jask',
'image' => 'aksjdksaj'
)
);
DB::table('services')->insert($services);
}
}
答案 0 :(得分:2)
您需要将Illuminate\Database\Seeder
导入ServiceTableSeeder
班级
<?php
use Illuminate\Database\Seeder;
class ServiceTableSeeder extends Seeder {
// ...