I am new to laravel I am trying to follow a tutorial in which I create a Database Seeder for the DB. So for that, I have used php artisan make:seeder ArticlesTableSeeder command
Seeder
class ArticlesTableSeeder extends Seeder
{
public function run()
{
// Let's truncate our existing records to start from scratch.
Article::truncate();
$faker = \Faker\Factory::create();
// And now, let's create a few articles in our database:
for ($i = 0; $i < 50; $i++) {
Article::create([
'title' => $faker->sentence,
'body' => $faker->paragraph,
]);
}
}
}
Now, when I run the php artisan db:seed --class=ArticlesTableSeeder command I have got this error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Article' not found
I do have a article modal
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
protected $fillable = ['title', 'body'];
}
What am I doing wrong here ? I have searched for this error and found the maximum of them are due to spelling mistakes. I think I don't have a spelling mistake here. What is wrong with this code ?
Help would be appreciated.