I am following the tutorial in "Laravel 5 Essentials." When I try to seed my database with the command
php artisan db:seed
I receive the error
[ReflectionException]
Class BreedsTableSeeder does not exist
The code for BreedsTableSeeder is defined below:
<?
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class BreedsTableSeeder extends Seeder {
public function run()
{
DB:table('breeds')->insert([
['id' => 1, 'name' => "Domestic"],
['id' => 2, 'name' => "Persian"],
['id' => 3, 'name' => "Siamese"],
['id' => 4, 'name' => "Abyssinian"],
]);
}
}
The DatabaseSeeder is defined as such:
<?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('BreedsTableSeeder');
}
}
1 I noticed that "DB" has a different color when I load sample code in Sublime, which makes me suspect that this has something to do with the DB namespace. Because I am new to Laravel, I am not sure where DB should be defined.
I also tried executing
composer dump-autoload
but that did not work. Does anyone know how to fix this problem? Thanks!
Try:
php artisan make:seeder BreedsTableSeeder
Details can be found - Laravel seeding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With