Skip to content

Instantly share code, notes, and snippets.

@lancepioch
Last active March 12, 2018 17:51
Show Gist options
  • Save lancepioch/1a80fe52f5b93fb3a57e to your computer and use it in GitHub Desktop.
Save lancepioch/1a80fe52f5b93fb3a57e to your computer and use it in GitHub Desktop.
HW
<?php
class UserTableSeeder extends Seeder {
public function run()
{
$now = Carbon::now('utc')->toDateTimeString();
DB::table('steams')->delete();
DB::table('users')->delete();
$group = new Group(config('services.steam.api'), config('services.steam.group'));
$members = $group->getMembers();
foreach ($members as $member) {
$user = new User(['name' => null, 'created_at' => $now, 'updated_at' => $now]);
$user->save();
$steam = new Steam([
'name' => $member->personaname,
'avatar' => $member->avatarfull,
'steam_id' => $member->steamid,
'last_logoff' => $member->lastlogoff,
'created_at' => $now,
'updated_at' => $now,
]);
$steam->user()->associate($user);
$steam->save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment