refactor: revamp the user seeder
This commit is contained in:
parent
c793596a3a
commit
43e6859366
0
app/Exceptions/AccountNotLinkedException.php
Normal file → Executable file
0
app/Exceptions/AccountNotLinkedException.php
Normal file → Executable file
0
app/Facades/Discord.php
Normal file → Executable file
0
app/Facades/Discord.php
Normal file → Executable file
0
app/Helpers/Discord.php
Normal file → Executable file
0
app/Helpers/Discord.php
Normal file → Executable file
0
app/Http/Controllers/Auth/DiscordController.php
Normal file → Executable file
0
app/Http/Controllers/Auth/DiscordController.php
Normal file → Executable file
0
app/Providers/DiscordOuthProvider.php
Normal file → Executable file
0
app/Providers/DiscordOuthProvider.php
Normal file → Executable file
@ -25,6 +25,7 @@ use App\Services\AccountSuspensionService;
|
||||
use App\Traits\HandlesAccountTokens;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@ -34,7 +35,7 @@ use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
use UserHasTeams, Notifiable, HasRoles;
|
||||
use UserHasTeams, Notifiable, HasRoles, HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
@ -37,6 +37,7 @@
|
||||
"barryvdh/laravel-debugbar": "^3.3",
|
||||
"barryvdh/laravel-ide-helper": "^2.12",
|
||||
"fakerphp/faker": "^1.19",
|
||||
"laravel/sail": "^1.15",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"phpunit/phpunit": "^9.3",
|
||||
|
62
composer.lock
generated
62
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9d78d96466ddbdc75d3952615e00aafc",
|
||||
"content-hash": "2b00362eaed0b6018ba0415a503c5079",
|
||||
"packages": [
|
||||
{
|
||||
"name": "almasaeed2010/adminlte",
|
||||
@ -9074,6 +9074,66 @@
|
||||
},
|
||||
"time": "2020-07-09T08:09:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/sail",
|
||||
"version": "v1.15.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/sail.git",
|
||||
"reference": "853dea1fa866a52a93beccc4e5affdc49b98e7d5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/sail/zipball/853dea1fa866a52a93beccc4e5affdc49b98e7d5",
|
||||
"reference": "853dea1fa866a52a93beccc4e5affdc49b98e7d5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^8.0|^9.0",
|
||||
"illuminate/contracts": "^8.0|^9.0",
|
||||
"illuminate/support": "^8.0|^9.0",
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/sail"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Sail\\SailServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Sail\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Docker files for running a basic Laravel application.",
|
||||
"keywords": [
|
||||
"docker",
|
||||
"laravel"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/sail/issues",
|
||||
"source": "https://github.com/laravel/sail"
|
||||
},
|
||||
"time": "2022-08-17T13:17:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "v1.18.0",
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\User>
|
||||
@ -17,7 +18,19 @@ class UserFactory extends Factory
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'uuid' => $this->faker->uuid(),
|
||||
'name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => Carbon::now(),
|
||||
'username' => $this->faker->userName(),
|
||||
'dob' => Carbon::now(),
|
||||
'password' => bcrypt($this->faker->password),
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
'password_last_updated' => Carbon::now(),
|
||||
'administratively_locked' => false,
|
||||
'registrationIp' => $this->faker->ipv4(),
|
||||
'currentIp' => $this->faker->ipv4(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
0
database/migrations/2022_08_27_052451_add_int_profile_pic_to_users.php
Normal file → Executable file
0
database/migrations/2022_08_27_052451_add_int_profile_pic_to_users.php
Normal file → Executable file
@ -34,144 +34,36 @@ class UserSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
|
||||
$ghostAccount = User::create([
|
||||
'uuid' => 'b741345057274a519144881927be0290', // Ghost
|
||||
'name' => 'Ghost (deleted account)',
|
||||
'email' => 'blackhole@example.com',
|
||||
'email_verified_at' => now(),
|
||||
'username' => 'ghost',
|
||||
'originalIP' => '0.0.0.0',
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => 'locked'
|
||||
])->assignRole('user'); // There can't be role-less users
|
||||
|
||||
$staffUsers = [
|
||||
|
||||
[
|
||||
'uuid' => 'd2b321b56ff1445db9d7794701983cad',
|
||||
'name' => 'Robot 1',
|
||||
'email' => 'tester1@example.com',
|
||||
'username' => 'tester1',
|
||||
'originalIP' => '99.18.146.235',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'ab22b5da02644953ace969fce85c0819',
|
||||
'name' => 'Robot 2',
|
||||
'email' => 'tester2@example.com',
|
||||
'username' => 'tester2',
|
||||
'originalIP' => '141.239.229.53',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'df38e6bf762944d3a600ded59a693ad1',
|
||||
'name' => 'Robot 3',
|
||||
'email' => 'tester3@example.com',
|
||||
'username' => 'tester3',
|
||||
'originalIP' => '25.63.20.97',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '689e446484824f6bad5064e3df0aaa96',
|
||||
'name' => 'Robot 4',
|
||||
'email' => 'tester4@example.com',
|
||||
'username' => 'tester4',
|
||||
'originalIP' => '220.105.223.142',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '172391f917bf418ab1c40ebc041ed5ba',
|
||||
'name' => 'Robot 5',
|
||||
'email' => 'tester5@example.com',
|
||||
'username' => 'tester5',
|
||||
'originalIP' => '224.66.76.60',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '371f34dcce2a4457bf385ab9417a2345',
|
||||
'name' => 'Robot 6',
|
||||
'email' => 'tester6@example.com',
|
||||
'username' => 'tester6',
|
||||
'originalIP' => '97.113.131.0',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '89aa5222855542bebe7a7780248ef5f9',
|
||||
'name' => 'Robot 7',
|
||||
'email' => 'tester7@example.com',
|
||||
'username' => 'tester7',
|
||||
'originalIP' => '15.160.137.222',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
$regularUsers = [
|
||||
|
||||
[
|
||||
'uuid' => '20f69f47e72f463493b5b91d1c05452f',
|
||||
'name' => 'User 1',
|
||||
'email' => 'user1@example.com',
|
||||
'username' => 'user1',
|
||||
'originalIP' => '253.25.237.78',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '5f900018241e4aaba7883f2d5c5c2357',
|
||||
'name' => 'User 2',
|
||||
'email' => 'user2@example.com',
|
||||
'username' => 'user2',
|
||||
'originalIP' => '82.92.156.176',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'ba9780c3270745c6840eaabe1bf8aa14',
|
||||
'name' => 'User 3',
|
||||
'email' => 'user3@example.com',
|
||||
'username' => 'user3',
|
||||
'originalIP' => '224.123.129.17',
|
||||
'password' => Hash::make('password')
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
foreach ($regularUsers as $regularUser)
|
||||
{
|
||||
$user = User::create($regularUser);
|
||||
Profile::create([
|
||||
'profileShortBio' => 'Random data ' . rand(0,1000),
|
||||
'profileAboutMe' => 'Random data ' . rand(0, 1000),
|
||||
'socialLinks' => "[]", // empty json set, not an array
|
||||
'avatarPreference' => 'gravatar',
|
||||
'userID' => $user->id
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($staffUsers as $staffUser)
|
||||
{
|
||||
$user = User::create($staffUser);
|
||||
Profile::create([
|
||||
'profileShortBio' => 'Random data ' . rand(0,1000),
|
||||
'profileAboutMe' => 'Random data ' . rand(0, 1000),
|
||||
'socialLinks' => "[]",
|
||||
'avatarPreference' => 'gravatar',
|
||||
'userID' => $user->id
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
User::create([
|
||||
'uuid' => '6102256abd284dd7b68e4c96ef313734',
|
||||
$admin = User::create(([
|
||||
'uuid' => 'b741345057274a519144881927be0290', // Ghost
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@example.com',
|
||||
'email' => 'admin@webvokestudio.pt',
|
||||
'email_verified_at' => now(),
|
||||
'username' => 'admin',
|
||||
'originalIP' => '192.168.1.2',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => Hash::make('admin')
|
||||
]))->assignRole('user', 'reviewer', 'hiringManager', 'admin');
|
||||
|
||||
foreach (User::all() as $user)
|
||||
{
|
||||
$user->assignRole('reviewer', 'user');
|
||||
$users = User::factory()
|
||||
->count(1500)
|
||||
->create();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user->assignRole('user');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<server name="DB_CONNECTION" value="sqlite"/>
|
||||
<server name="DB_DATABASE" value=":memory:"/>
|
||||
<server name="MAIL_MAILER" value="array"/>
|
||||
<server name="QUEUE_CONNECTION" value="sync"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user