Jeff Madsen has a quick post to his site showing how to use Faker to populate data in Laravel directly in the framework's generated "seeders".
Hello, Mr. asdfgh qweefg! Welcome to kgjhjgjh! Thank you. Only the name's not "asdfgh qweefg".
Sorry! It's just easier.. You're always showing everyone on Laravel Quick Tips these helpful little tricks. Why not show them how to give me a proper name?
He includes an example of creating a
Faker object in the seeder and using it to make name, email, age and city values. Naturally, not everyone's going to have English names or locations, so he shows how to set the language, locale and a few other tips:
- shortcuts for optional data
- randomized email addresses
- random elements from a given set
He also mentions custom providers but points to the Faker documentation for a bit more information about that.