0

I'm using Lumen and working through a 12 month-old tutorial.

While attempting to run php artisan db:seed, I'm getting the following error:

  [Symfony\Component\Debug\Exception\FatalThrowableError]  
  Class 'App\Models\Quote' not found    

However I created the Models sub-directory and Quote.php within that directory. Here is that code:

<?php

# app/Models/Quote.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

final class Quote extends Model  
{

}

Within database/seeds I have two files: QuoteTableSeeder.php & the default DatabaseSeeder.php. I added $this->call('QuoteTableSeeder'); to the run() method of DatabaseSeeder.php.

Here are the contents of QuoteTableSeeder.php:

<?php

# database/seeds/QuoteTableSeeder.php

use App\Models\Quote;
use Illuminate\Database\Seeder;

class QuoteTableSeeder extends Seeder
{
    public function run()
    {
        Quote::create([
            'text' => 'Success is going from failure to failure without losing your enthusiasm',
            'author' => 'Winston Churchill',
            'background' => '1.jpg'
        ]);

    }
}

I have already ran composer dump-autoload which fixed a previous error but now causes the above-mentioned issue.

What am I doing wrong?

sparecycle
  • 2,038
  • 5
  • 31
  • 58
  • Did you run `composer dumpautoload` first? – aynber Jun 14 '16 at 16:54
  • Yes @anyber, which fixed the previous error: [ReflectionException] Class QuoteTableSeeder does not exist – sparecycle Jun 14 '16 at 16:55
  • Eh, honestly, it's probably just some cache problem. Everything looks good here, can you try doing a `dumpautoload` with the `-o` flag and a `composer update`, then give it another go? – Ohgodwhy Jun 14 '16 at 17:17
  • I have the same problem. Have you got the solution? I guess lumen doesn't include db seed? – Richard Fu Jan 14 '19 at 07:20

0 Answers0