1

I am trying to seed some info on my oneway table but evertime I run php artisan db:seed, an error would occur

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Class 'Oneway' not found","file":"C:\\wamp\\www\\airlines\\app\\database
\\seeds\\OnewayTableSeeder.php","line":8}}

I have tried composer dump-autoload but still nothing happens. What seems to be the problem here? Is it on my composer or my codes.

OnewayTableSeeder.php

 <?php

class OnewayTableSeeder extends Seeder{
    public function run()
    {
        DB::table('oneway')->delete();

        Oneway::create(
        array(
            'destination-from'=>'Bacolod',
            'destination-to'=>'Cebu',
            'departure'=> \Carbon\Carbon::createFromDate(2014,10,01)->toDateTimeString(), 
        ));

        Oneway::create(
        array(
            'destination-from'=>'Tawi-Tawi',
            'destination-to'=>'Cebu',
            'departure'=> \Carbon\Carbon::createFromDate(2014,10,03)->toDateTimeString(), 
        ));

        Oneway::create(
        array(
            'destination-from'=>'Cebu',
            'destination-to'=>'Dipolog',
            'departure'=> \Carbon\Carbon::createFromDate(2014,10,16)->toDateTimeString(), 
        ));
    }

}

DatabaseSeeder.php

    <?php

class DatabaseSeeder extends Seeder {

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Eloquent::unguard();

        // $this->call('UserTableSeeder');
         $this->call('OnewayTableSeeder');
    }

}
jrenk
  • 1,387
  • 3
  • 24
  • 46
staphhelpme
  • 55
  • 2
  • 13

1 Answers1

3

There is someone else who had a similar problem with migrations.

Laravel 4 migration: class not found exception

This might just work for you.

Other than this, make sure you have a model for OneWay and also make sure that the seeder file is named exactly OnewayTableSeeder.php. Moreover try using this package fzaninotto/Faker to seed your database. I know that the library isn't relevant to the question you asked but it comes in very handy.

Also I personally tried removing either the model or the seeder file and it gives me a different exception than yours. All I can find everywhere is that the seeder file was not included and you should run composer dump-autoload or composer dumpautoload. Try both of them just for the sake of it.

Community
  • 1
  • 1
Rohan
  • 13,308
  • 21
  • 81
  • 154