Skip to content

Commit 0ed6895

Browse files
committed
Merge pull request #22 from webtechnick/master
Using Faker
2 parents 8c22576 + e803206 commit 0ed6895

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎Console/Command/PopulateShell.php‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,32 @@ class PopulateShell extends AppShell {
77

88
public function main() {
99
$this->out('Inserting Elastic Search.');
10+
$faker = Faker\Factory::create();
1011
$this->User->switchToElastic();
1112
$count = 100;
1213
$this->ProgressBar->start($count);
13-
for($i = 1; $i <= $count; $i++) {
14-
$rand = mt_rand(1000,20000);
15-
$rand = $rand / 20000;
14+
for($i = 1; $i <= $count; $i++){
1615
$lat_lon = array(
17-
'lat' => 37.630275 + $rand,
18-
'lon' => -122.359886 - $rand
16+
'lat' => $faker->latitude, //37.630275 + $rand,
17+
'lon' => $faker->longitude //-122.359886 - $rand
1918
);
2019
$data = array(
2120
'id' => String::uuid(),
22-
'full_name' => "Awesome $i Baker",
23-
'first_name' => "Awesome",
24-
'last_name' => "Baker",
21+
'full_name' => $faker->name,
22+
'first_name' => $faker->firstName,
23+
'last_name' => $faker->lastName,
2524
'facebook_id' => $i,
26-
'companies' => [array(
25+
'companies' => array(array(
2726
'id' => String::uuid(),
28-
'name' => "CakeOCD $i",
29-
'street' => "123 main street",
30-
'city' => "Gotham",
31-
'state' => "NY",
32-
'country' => "DC",
33-
'zip' => "12345",
34-
'website' => "http://cakephp.org",
27+
'name' => $faker->company,
28+
'street' => $faker->streetAddress,
29+
'city' => $faker->city,
30+
'state' => $faker->stateAbbr,
31+
'country' => $faker->country,
32+
'zip' => $faker->postcode,
33+
'website' => $faker->url,
3534
'location' => $lat_lon
36-
)],
35+
)),
3736
'created' => '2013-08-30 12:00:00',
3837
'modified' => '2013-08-30 12:00:00'
3938
);

‎composer.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"friendsofcake/crud" : "dev-develop",
1414
"slywalker/twitter_bootstrap": "dev-master",
1515
"facebook/php-sdk": "dev-master",
16-
"dkullmann/cakephp-elastic-search-datasource": "dev-master"
16+
"dkullmann/cakephp-elastic-search-datasource": "dev-master",
17+
"fzaninotto/Faker": "dev-master"
1718
},
1819
"require-dev": {
1920
"phpunit/phpunit": "3.7.*"

0 commit comments

Comments
 (0)