T
T
The Dragger2015-06-11 18:02:59
Laravel
The Dragger, 2015-06-11 18:02:59

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),
            ]);
        }
    }

}

DatabaseSeeder.php
<?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();
    }
}

I write in the terminal php artisan db:seed
and get this error [ReflectionException]
Class PostsSeeder does not exist
why is everything correct?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cloud_zurbag, 2015-06-11
@IPD2

You need to update the
composer dump composer dump-autoload

M
Mokhirjon Naimov, 2015-06-11
@zvermafia

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 question

Ask a Question

731 491 924 answers to any question