Questions tagged [laravel-seeding]

Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in the database/seeds directory. Seed classes may have any name you wish but probably should follow some sensible convention, such as UsersTableSeeder, etc. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in the database/seeds directory. Seed classes may have any name you wish, but probably should follow some sensible convention, such as UsersTableSeeder, etc. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

Example Database Seed Class

class DatabaseSeeder extends Seeder {

    public function run()
    {
        $this->call('UserTableSeeder');

        $this->command->info('User table seeded!');
    }

}

class UserTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();

        User::create(['email' => 'foo@bar.com']);
    }

}

To seed your database, you may use the db:seed command on the Artisan CLI:

php artisan db:seed

By default, the db:seed command runs the DatabaseSeeder class, which may be used to call other seed classes. However, you may use the --class option to specify a specific seeder class to run individually:

php artisan db:seed --class=UserTableSeeder

You may also seed your database using the migrate:refresh command, which will also rollback and re-run all of your migrations:

php artisan migrate:refresh --seed
257 questions
-1
votes
1 answer

mcrypt_decrypt not returning correct data only when used in Laravel seeding

We are using the built in Database Seeding in Laravel 5.3 under PHP 7.0 on Windows. Problem is that whenever we use mcrypt_encrypt to encrypt some data, the data we get back from mcrypt_decrypt is not the same as what we passed in. $data =…
Randar Puust
  • 193
  • 3
  • 11
-8
votes
1 answer

Has anyone encountered this on Algolia in laravel seeding?

Has anyone encountered this error when seeding? I had to comment the namespaces of scout and algolia to make the seeding work. Any ideas? Here is a screenshot of my code. Here is a screenshot of my error.
1 2 3
17
18