Laravel seeder gives error. Class not found
EDIT
Now I see, the problem is with your login
class (with earlier question formatting the exact error was illegible). You should look again what's the name of file where you have login
class and what's the name of class. The convention is that the file should have name Login.php
(with capital letter) and the name of class also should be Login
(with capital letter). You should also check in what namespace is your Login
class. If it is defined in in App
namespace, you should add to your LoginTableSeeder
:
use App\Login;
in the next line after <?php
so basically the beginning of your file should look like this:
<?php
use App\Login;
use Illuminate\Database\Seeder;
EARLIER ANSWER
You didn't explained what the exact error is (probably the error is for Seeder
class) but:
In database/seeds/DatabaseSeeder.php
you should run Login seeder like this:
$this->call('LoginTableSeeder');
You should put into database/seeds
file LoginTableSeeder.php
with capital letter at the beginning.
Now, your file LoginTableSeeder.php
file should look like this:
<?php
use Illuminate\Database\Seeder;
class LoginTableSeeder extends Seeder
{
public function run()
{
// your code goes here
}
}
you need to import Seeder
with use
at the beginning of file and again class name should start with capital letter.
Now you should run composer dump-autoload
and now when you run php artisan db:seed
it will work fine.
Just run
composer dump-autoload -o
for the autoloader to pick up the newly classes because the database folder is not automatically autoloaded with PSR-4.
You need to create an Eloquent model for that table in order to use Login::create()
. You can do that with a simple artisan command:
$ php artisan generate:model Login
This will generate a new Eloquent model in app/models
directory which should look like this.
class Login extends Eloquent {
protected $fillable = [];
protected $table = 'login';
}
Your code should work after that. If it still doesn't make sure you run composer dump-autoload
.