php artisan db:seed 报错!!!
错误代码:
**************************************************************************
C:\wamp\www\learnlaravel5>php artisan db:seed
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\Article' not found
C:\wamp\www\learnlaravel5>
**************************************************************************
【 DatabaseSeeder.php】
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call(ArticleSeeder::class);
}
}
【ArticleSeeder.php】
<?php
use Illuminate\Database\Seeder;
class ArticleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::table('articles')->delete();
for ($i=0; $i < 10; $i++) {
\App\Article::create([
'title' => 'Title '.$i,
'body' => 'Body '.$i,
'user_id' => 1,
]);
}
}
}
**************************************************************************
C:\wamp\www\learnlaravel5>php artisan db:seed
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\Article' not found
C:\wamp\www\learnlaravel5>
**************************************************************************
【 DatabaseSeeder.php】
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call(ArticleSeeder::class);
}
}
【ArticleSeeder.php】
<?php
use Illuminate\Database\Seeder;
class ArticleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::table('articles')->delete();
for ($i=0; $i < 10; $i++) {
\App\Article::create([
'title' => 'Title '.$i,
'body' => 'Body '.$i,
'user_id' => 1,
]);
}
}
}
0 个回复