-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeder.php
53 lines (41 loc) · 1.7 KB
/
seeder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require_once "vendor/autoload.php";
class seeder extends \Faker\Factory{
private $faker;
private $sicks;
public function __construct()
{
$this->faker = \Faker\Factory::create();
$this->sicks = ['AIDS','Cancer','Deaf','physical_disability','Trans','short'];
}
public function getusername(){
$country = $this->faker->country;
return [
'name' => $this->faker->name,
'birthday' => $this->faker->dateTimeBetween('-55 years', '-8 years'),
'username' => $this->faker->userName,
'mail' => $this->faker->email,
'password' => '$2a$12$fL1RGfcU6IWOlRlDE1eoVOUci8YmnUca8UQZ5Vks/I2pDFiC1pFja', // 11111111
'bio' => $this->faker->text(200),
'lat' => $this->faker->latitude,
'lng' => $this->faker->longitude,
'city' =>$this->faker->address()->latitude,
'sickness' => $this->sicks[rand(0,count($this->sicks))],
'avatar' => 'photo'.rand(0,10).'.jpg'
];
}
public function run(){
include "config/config.php";
global $conn;
$sql = array();
foreach(range(0,100) as $i){
// $username = $this->getusername();
$sql[] = '("'.$this->faker->name.'", "'.$this->faker->date().'"
, "'.$this->faker->userName.'","'.$this->faker->email.'", "$2a$12$fL1RGfcU6IWOlRlDE1eoVOUci8YmnUca8UQZ5Vks/I2pDFiC1pFja"
, "this is my bio", "'.$this->sicks[rand(0,count($this->sicks)-1)].'", "photo'.rand(0,10).'.jpg")';
}
$sql = implode(',', $sql);
$conn->query('INSERT INTO user (name,birthday,username,mail,password,bio,sickness,avatar) VALUES '. $sql);
}
}
?>