i am using faker generate to generate fake entries and insert it into database with the help of php artisan db:seed when i run this command it shows an error :
Seeding: TodosTableSeeder
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'APP\Todo' not found
at /var/www/html/todos/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:217 213| if ($this->amount < 1) { 214| return (new $this->class)->newCollection(); 215| } 216|
217| $instances = (new $this->class)->newCollection(array_map(function () use ($attributes) { 218| return $this->makeInstance($attributes); 219| }, range(1, $this->amount))); 220| 221| $this->callAfterMaking($instances);
Exception trace:
1 Illuminate\Database\Eloquent\FactoryBuilder::make([]) /var/www/html/todos/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:167
2 Illuminate\Database\Eloquent\FactoryBuilder::create() /var/www/html/todos/database/seeds/TodosTableSeeder.php:15
Please use the argument -v to see more details.
here is my code UserFactory.php
<?php
use Faker\Generator as Faker;
$factory->define(App\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
$factory->define(App\Todo::class, function(Faker $faker) {
return[
'todos' => $faker->sentence(10)
];
});
TodosTableSeeder.php
<?php
use App\Todo;
use Illuminate\Database\Seeder;
class TodosTableSeeder extends Seeder
{
public function run()
{
factory(APP\Todo::class, 10)->create() ;
}
}
DatabaseSeeder.php
<?php
use App\Todo;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run()
{
//$this->call(UsersTableSeeder::class);
$this->call(TodosTableSeeder::class);
}
}
factory(App\Todo::class, 10)->create() ;
instead. Capitalization matters. – aynberAPP
is not the same asApp
– aynber