'How to Seed created Laravel Field

Hello Everyone I have a question: I am a new lo Laravel and I'm wondering is there is a way to seed a newly created column? I created a new column using migration command:

php artisan migration:make --table Authors

I created a new field image, now I want to populate it with www.thispersondoesntexists.com images. Is there a way to do that for every existing record in my database?



Solution 1:[1]

Add the following fields in your seeders file which is located in database -> seeders -> DatabaseSeeder.

DB::table('users')->insert([
    'name' => Str::random(10),
    'email' => Str::random(10).'@gmail.com',
    'password' => Hash::make('password'),
]);

here add your table name and table fields.Then use the following command.
php artisan make:seeder DatabaseSeeder

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ohidul