Answer the question
In order to leave comments, you need to log in
Can't see Class (Seeder, Laravel 5.1)?
PostsSeeder.php
<?php
use Illuminate\Database\Seeder;
use Faker\Factory as Faker;
use \App\Models\Post as Post;
class PostsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
Post::truncate();
for($i = 0; $i < 5; $i++){
Post::create([
'title'=>$faker->word(2),
'body'=>$faker->paragraph(20),
// 'preview'=>$faker->imageUrl(200,200 ),
// 'author'=>$faker->name(1),
]);
}
}
}
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call('PostsSeeder');
Model::reguard();
}
}
Answer the question
In order to leave comments, you need to log in
In my opinion, since version 5.0 , you need to write namespace in each file . And you don't have them!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question