Am getting an error when i try to seed my database in laravel 5.4 using faker
use Illuminate\Database\Seeder;
use app\PostModell;
class postcarseeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Let's truncate our existing records to start from scratch.
PostModell::truncate();
$faker = \Faker\Factory::create();
// And now, let's create a few articles in our database:
for ($i = 0; $i < 50; $i++) {
PostModell::create([
'title' => $faker->sentence,
'body' => $faker->paragraph,
]);
}
}
Above is my seeder class which am calling in my DatabaseSeeder.php with the following command $this->call(postcarseeder::class);
so that i can run php artisan db:seed
You should use full namespace:
App\PostModell
Or add this to the top of the seeder class:
use App\PostModell;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.