Created
August 4, 2017 21:39
-
-
Save bmadigan/fcb758b139caac14033daf052713df90 to your computer and use it in GitHub Desktop.
Laravel - An array to a collection with a loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup some developer accounts to test with | |
$developers = [ | |
['name' => 'Tony Richards', 'email' => '[email protected]', 'password' => 'secret'], | |
['name' => 'Brad Madigan', 'email' => '[email protected]', 'password' => 'secret'] | |
]; | |
collect($developers)->each(function($dev) { | |
factory(\App\Models\User::class)->create([ | |
'name' => $dev['name'], | |
'email' => $dev['email'], | |
'password' => bcrypt($dev['password']), | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment