0

I am facing below error while I am trying to run php artisan db:seed . I ran composer update and composer dump-autoload before.

enter image description here

User.php

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use Notifiable, HasApiTokens;
    protected $fillable = ['name', 'email', 'password',];
    protected $hidden = ['password', 'remember_token',];
}

Address.php

use Illuminate\Database\Eloquent\Model;

class Address extends Model
{
    protected $fillable = ['user_id', 'name', 'address','mobile_no','image','email'];

    public function users() {
        return $this->hasOne(User::class);
    }
}

DatabaseSeeder.php

class DatabaseSeeder extends Seeder
{
    public function run()
    {
        $this->call(UsersTableSeeder::class);
        $this->call(AddressessTableSeeder::class);
    }
}

UsersTableSeeder.php

class UsersTableSeeder extends Seeder
{
    public function run()
    {
        factory(App\User::class,10)->create();
    }
}

AddressessTableSeeder.php

class AddressessTableSeeder extends Seeder
{
    public function run()
    {
        factory(\App\Address::class, 50)->create()->each(function ($u) {
            $u->users()->save(factory(App\Post::class)->make());
        });
    }
}

Here is my model and seeder files.I could not find out why the error is coming out.

abu abu
  • 6,599
  • 19
  • 74
  • 131
  • Try installing doctrine/dbal and see what you get. the MySql driver is standard in Laravel. Are your .env and config/database.php settings correctly set? Can the framework read data? What test environment did you set up? – Dimitri Mostrey Dec 07 '17 at 07:09
  • Thanks @DimitriMostrey for your reply. Yes, My .env and config/database.php settings correctly set, because before this issue it was working properly. I didn't set up any test environment. – abu abu Dec 07 '17 at 07:15
  • Strange. In you seeder, I presume you use DB::table('users')->insert(''username" => 'administrator', ....) and the database.php setting is 'default' => env('DB_CONNECTION', 'mysql'), What happens if you try to create a record in php artisan tinker? – Dimitri Mostrey Dec 07 '17 at 07:24
  • Thanks @DimitriMostrey for your reply. I added **Model** and **Seeder** files. I think those are helpful for you. Thanks – abu abu Dec 07 '17 at 08:29
  • do you have the mysql PDO driver installed/enabled? doesn't seem so – lagbox Dec 07 '17 at 09:47
  • I didn't install any driver. How can I do that ? – abu abu Dec 07 '17 at 09:56

0 Answers0