Skip to content

Commit d1b5a44

Browse files
committed
Some fixes
1 parent 007e381 commit d1b5a44

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Console/Commands/AssignRole.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function attachRole(Model $user, Model $role, array $config)
5858
try {
5959
$reflection = new ReflectionClass(new $user);
6060

61-
if (!$reflection->hasMethod($roleMethod)) {
61+
if (null === $roleMethod || !$reflection->hasMethod($roleMethod)) {
6262
$relation = null;
6363

6464
if ($reflection->hasMethod('roles')) {

src/Console/Commands/Sanitize.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Illuminate\Database\Eloquent\Builder;
88
use Illuminate\Database\Eloquent\Model;
9-
use Illuminate\Support\Collection;
109
use RuntimeException;
1110

1211
/**
@@ -38,14 +37,18 @@ public function handle()
3837
$emailColumn = $this->getEmailColumn($config);
3938
$users = $this->getUsers($config);
4039

41-
$users->each(function (Collection $chunk) use ($emailColumn, $domain) {
42-
$chunk->each(function (Model $user) use ($emailColumn, $domain) {
43-
$email = $user->getAttribute($emailColumn);
44-
$newEmail = preg_replace('/@(.*)$/', "@{$domain}-$1", $email);
40+
$sanitized = 0;
4541

46-
$user->update([$emailColumn => $newEmail]);
47-
});
42+
$users->each(function (Model $user) use ($emailColumn, $domain, &$sanitized) {
43+
$email = $user->getAttribute($emailColumn);
44+
$newEmail = preg_replace('/@(.*)$/', "@{$domain}-$1", $email);
45+
46+
$user->update([$emailColumn => $newEmail]);
47+
48+
$sanitized++;
4849
});
50+
51+
$this->info("Successfully sanitized {$sanitized} emails");
4952
}
5053

5154
/**

0 commit comments

Comments
 (0)