95 lines
2.6 KiB
PHP
95 lines
2.6 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Libraries\UuidHelper;
|
|
use Faker\Factory as Faker;
|
|
use App\Helpers\StringHelper;
|
|
|
|
class MemberSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
DB::table('loyalty_card')->truncate();
|
|
DB::table('personal_details')->truncate();
|
|
DB::table('users')->where('type',2)->delete();
|
|
|
|
$personal_details = array();
|
|
$loyalty_card = array();
|
|
$users = array();
|
|
|
|
for ($i=1; $i <= 200; $i++)
|
|
{
|
|
$uuid = new UuidHelper;
|
|
$pd_uuid = $uuid->generate_uuid1();
|
|
$lcard_uuid = $uuid->generate_uuid1();
|
|
$faker = Faker::create();
|
|
|
|
$lastName = $faker->lastName;
|
|
$firstName = $faker->firstName;
|
|
|
|
$registration = $faker->dateTimeBetween($startDate = '-5 days', $endDate = 'now');
|
|
$valitated = rand(0,1) ? $faker->dateTimeBetween($startDate = '-5 days', $endDate = 'now') : false;
|
|
|
|
$personal_details[] = array(
|
|
'pd_uuid' => $pd_uuid,
|
|
'firstname' => $firstName,
|
|
'middlename' => '',
|
|
'lastname' => $lastName,
|
|
'photo' => '',
|
|
'birthdate' => '1994-11-25 00:00:00',
|
|
'address' => 'Pembo Makati City',
|
|
'created_at' => $registration,
|
|
'created_by' => 0
|
|
);
|
|
|
|
$card_number = StringHelper::random_num(16);
|
|
|
|
$loyalty_card[] = array(
|
|
'lcard_uuid' => $lcard_uuid,
|
|
'pd_id' => $i,
|
|
'lcard_s_id' => 0,
|
|
'card_number' => $card_number,
|
|
'pin' => (12345678 + $i),
|
|
'cardtype_id' => 1,
|
|
'expiry_date' => '2020-11-25 00:00:00',
|
|
'birthdate' => '1994-11-25',
|
|
'mobile' => '09155664820',
|
|
'email' => strtolower($firstName."_".$lastName)."@qqqq.com",
|
|
'civilstatus_id' => 1,
|
|
'gender_id' => 1,
|
|
'vo_id' => 1,
|
|
'is_validated' => $valitated ? 1 : 0,
|
|
'validation_dt' => $valitated ? $valitated : 0,
|
|
'is_locked' => $i > 10 ? 1 : 0,
|
|
'lock_code' => $i > 10 ? '01' : '',
|
|
'lock_dt' => $i > 10 ? date('Y-m-d H:i:s') : '',
|
|
'created_at' => $registration,
|
|
'last_synchronized' => date('Y-m-d H:i:s'),
|
|
);
|
|
|
|
$users[] = array(
|
|
"name" => $firstName." ".$lastName,
|
|
"username" => $card_number,
|
|
"email" => strtolower($firstName."_".$lastName)."@qqqq.com",
|
|
"type" => 2,
|
|
"password" => bcrypt('19941125'),
|
|
"remember_token" => 1
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
DB::table('personal_details')->insert($personal_details);
|
|
DB::table('loyalty_card')->insert($loyalty_card);
|
|
DB::table('users')->insert($users);
|
|
|
|
}
|
|
}
|