Guest012393
Guest012393

Reputation: 255

Issue with seeds Laravel 5

when I run: php artisan db:seed i get the following error message: reflection exception, class ServiceTableSeeder dos not exist. I tried to run: composer dump-autoload and now i get this error message:

[Symfony\Component\Debug\Exception\FatalErrorException] Class 'Seeder' not found

How can I fix it?

this is my databaseSeeder:

<?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(UserTableSeeder::class);

        $this->call('ServiceTableSeeder');
    }
}

and this is my ServiceTableSeeder:

<?php

class ServiceTableSeeder extends Seeder {

    public function run() {

        DB::table('services')->delete();

        $services = array (

            array(
                'title' => 'kdcsv',
                'description' => 'kasdks',
                'long_description' => 'asjdkas asjdsjkj sjdk',
                'image_thumb' => 'jask',
                'image' => 'aksjdksaj'
            ),

            array(
                'title' => 'blabla',
                'description' => 'kasdks',
                'long_description' => 'asjdkas asjdsjkj sjdk',
                'image_thumb' => 'jask',
                'image' => 'aksjdksaj'
            )

        );

        DB::table('services')->insert($services);

    }


}

Upvotes: 0

Views: 91

Answers (1)

deefour
deefour

Reputation: 35350

You need to import Illuminate\Database\Seeder into your ServiceTableSeeder class

<?php

use Illuminate\Database\Seeder;

class ServiceTableSeeder extends Seeder {

    // ...

Upvotes: 2

Related Questions