Last active
April 15, 2020 19:03
-
-
Save MillerAdulu/5d3da961639e62fe05ad7c800c3cd383 to your computer and use it in GitHub Desktop.
Seed data with foreign keys
This file contains 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
<?php | |
use Faker\Generator as Faker; | |
use App\Member; | |
$factory->define(App\MemberDeposit::class, function (Faker $faker) { | |
$members = Member::all()->pluck('member_id')->toArray(); | |
return [ | |
'member_id' => $faker->randomElement($members), | |
'payment_method_id' => $faker->randomElement($payment_methods), | |
'deposit_amount' => $faker->randomFloat(2, 0, 999999), | |
'comment' => $faker->word | |
]; | |
}); |
This file contains 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
<?php | |
use App\MaritalStatus; | |
use Faker\Generator as Faker; | |
$factory->define(App\Member::class, function (Faker $faker) { | |
$marital_statuses = MaritalStatus::all()->pluck('marital_status_id')->toArray(); | |
return [ | |
'identification_number' => $faker->ean13, | |
'first_name' => $faker->firstName, | |
'last_name' => $faker->lastName, | |
'other_name' => $faker->word, | |
'date_of_birth' => $faker->date('Y-m-d', 'now'), | |
'phone_number' => $faker->e164PhoneNumber, | |
'email' => $faker->email, | |
'kra_pin' => $faker->swiftBicNumber, | |
'gender' => $faker->boolean, | |
'passport_photo' => $faker->imageUrl($width = 200, $height = 200), | |
'marital_status_id' => $faker->randomElement($marital_statuses), | |
'proposed_monthly_deposit' => $faker->randomFloat(2, 0, 999999), | |
]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment