Skip to content

Commit 86a3b7f

Browse files
committed
Avoid making a lengthly trip to uifaces.com
1 parent b5dfc68 commit 86a3b7f

File tree

2 files changed

+297
-6
lines changed

2 files changed

+297
-6
lines changed

database/seeds/DatabaseSeeder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ class DatabaseSeeder extends Seeder {
77

88
public $faker;
99

10+
private $avatars;
11+
1012
/**
1113
* Run the database seeds.
1214
*
1315
* @return void
1416
*/
1517
public function run()
1618
{
19+
$this->avatars = json_decode(file_get_contents(__DIR__ . '/avatars.json'), true);
20+
1721
Model::unguard();
1822
$this->faker = Faker\Factory::create();
1923

@@ -90,13 +94,9 @@ public function insertVotes($user, $team)
9094

9195
public function getAvatar()
9296
{
93-
$client = new GuzzleHttp\Client();
94-
$response = $client->get('http://uifaces.com/api/v1/random');
95-
$response->getBody();
96-
$res = $response->json();
97-
$avatar = $res['image_urls']['epic'];
97+
$index = array_rand($this->avatars, 1);
9898

99-
return $avatar;
99+
return $this->avatars[$index];
100100
}
101101

102102
public function getRandNum($min = '', $max = '')

0 commit comments

Comments
 (0)