0

When running php artisan migrate --seed, this error appears:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'CreateCharactersTable' not found. 

Here is that that class:

<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class CharacterSeeder extends Seeder
{
 public function run()
 {
 DB::table('characters')->delete();
 DB::table('characters')->insert([
 'user_id' => 999,
 'name' => 'Susan Strong',
 'race' => 'orc',
 'class' => 'assassin',
 'image_location' => null,
 'combat_level' => '0',
 'base_str' => 6,
 'base_int' => 4,
 'base_apt' => 5,
 'mod_str' => 9,
 'mod_int' => 5,
 'mod_apt' => 7,
 'xp_str' => 1,
 'xp_int' => 2,
 'xp_apt' => 1,
 'is_bot' => 1,
 'created_at'=> '2017-04-02 17:53:02',
 'updated_at'=> '2017-04-02 17:53:02'
 ]);
 DB::table('characters')->insert([
 'user_id' => 4,
 'name' => 'Chale',
 'race' => 'elf',
 'class' => 'scholar',
 'image_location' => null,
 'combat_level' => '0',
 'base_str' => 3,
 'base_int' => 7,
 'base_apt' => 5,
 'mod_str' => 6,
 'mod_int' => 10,
 'mod_apt' => 6,
 'xp_str' => 1,
 'xp_int' => 2,
 'xp_apt' => 1,
 'is_bot' => 1,
 'created_at'=> '2017-04-02 17:53:02',
 'updated_at'=> '2017-04-02 17:53:
 }
}
?>

and the seeder:

<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Database\Seeds\CharacterSeeder;
use Database\Seeds\ClassesTableSeeder;
use Database\Seeds\RacesTableSeeder;
use Database\Seeds\UserTableSeeder;
class DatabaseSeeder extends Seeder
{
 /**
 * Run the database seeds.
 *
 * @return void
 */
 public function run()
 {
 $this->call(UserTableSeeder::class);
 $this->call(CharacterSeeder::class);
 $this->call(RacesTableSeeder::class);
 $this->call(ClassesTableSeeder::class);
 }
}

Running composer dumpautoload passes but does not remove the error. When it was only two seeders, User and Character, it ran well. Despite looking over the new seeders again and again, I cannot determine the error involved.

Any suggestions to get the seeder to run?

Thank you.

asked Apr 7, 2017 at 4:09
2
  • 2
    do composer dump-autoload and try to run seed again Commented Apr 7, 2017 at 4:13
  • @sumit as described in the question, this has no effect. Commented Apr 7, 2017 at 14:08

3 Answers 3

15

If you manually added the seeder files you should first run composer dump-autoload. This will regenerate the autoload_classmap.php file for you, see Composer Dump-Autoload for more info.

answered Jun 29, 2017 at 14:52

Comments

1

You've imported all your seeders from a namespace, but they aren't in a namespace.

use Database\Seeds\CharacterSeeder;
use Database\Seeds\ClassesTableSeeder;
use Database\Seeds\RacesTableSeeder;
use Database\Seeds\UserTableSeeder;

Just remove those lines and you should be good to go.

answered Apr 7, 2017 at 4:19

Comments

0

Class 'CreateCharactersTable' should is Migration. You need check this migration file or class exists.

if you only use seeder . you can exec php artisan db:seed

answered Apr 7, 2017 at 4:19

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.