Update AdminController.php
This commit is contained in:
parent
522e5f9d21
commit
075f3600f3
|
@ -166,9 +166,25 @@ public function SendTestMail(Request $request)
|
||||||
return implode('', $pieces);
|
return implode('', $pieces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$names = User::pluck('name')->toArray();
|
||||||
|
|
||||||
|
$adminCreatedNames = array_filter($names, function($name) {
|
||||||
|
return strpos($name, 'Admin-Created-') === 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
$numbers = array_map(function($name) {
|
||||||
|
return (int) str_replace('Admin-Created-', '', $name);
|
||||||
|
}, $adminCreatedNames);
|
||||||
|
|
||||||
|
$maxNumber = !empty($numbers) ? max($numbers) : 0;
|
||||||
|
$newNumber = $maxNumber + 1;
|
||||||
|
|
||||||
|
$domain = parse_url(url(''), PHP_URL_HOST);
|
||||||
|
$domain = ($domain == 'localhost') ? 'example.com' : $domain;
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => 'Admin-Created-' . random_str(8),
|
'name' => 'Admin-Created-' . $newNumber,
|
||||||
'email' => random_str(8) . '@example.com',
|
'email' => strtolower(random_str(8)) . '@' . $domain,
|
||||||
'password' => Hash::make(random_str(32)),
|
'password' => Hash::make(random_str(32)),
|
||||||
'role' => 'user',
|
'role' => 'user',
|
||||||
'block' => 'no',
|
'block' => 'no',
|
||||||
|
|
Loading…
Reference in New Issue