-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kreaweb.be
committed
Apr 28, 2024
1 parent
bd4da33
commit 0ca8dce
Showing
1 changed file
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
use App\Models\Team; | ||
use App\Models\User; | ||
use App\Models\Userlog; | ||
use Illuminate\Database\Seeder; | ||
use Laravel\Jetstream\Jetstream; | ||
|
||
|
@@ -14,7 +15,7 @@ public function run() | |
// ----------------------------------------------------------------------------------- | ||
// create developer users | ||
// ----------------------------------------------------------------------------------- | ||
User::factory([ | ||
$developer = User::factory([ | ||
'firstname' => '_', | ||
'surname' => 'Developer', | ||
'email' => '[email protected]', | ||
|
@@ -23,6 +24,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($developer); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------- | ||
// create administrator user | ||
// ----------------------------------------------------------------------------------- | ||
|
@@ -34,6 +39,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($administrator); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------- | ||
// create demo teams (owned by administrator) | ||
// ----------------------------------------------------------------------------------- | ||
|
@@ -67,6 +76,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($manager); | ||
} | ||
|
||
$team_british_royals->users()->attach( | ||
Jetstream::findUserByEmailOrFail($manager->email), | ||
['role' => 'manager'] | ||
|
@@ -82,6 +95,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($editor); | ||
} | ||
|
||
$team_kennedy->users()->attach( | ||
Jetstream::findUserByEmailOrFail($editor->email), | ||
['role' => 'editor'] | ||
|
@@ -101,6 +118,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($user); | ||
} | ||
|
||
$team_british_royals->users()->attach( | ||
Jetstream::findUserByEmailOrFail($user->email), | ||
['role' => 'member'] | ||
|
@@ -117,6 +138,10 @@ public function run() | |
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($user); | ||
} | ||
|
||
$team_kennedy->users()->attach( | ||
Jetstream::findUserByEmailOrFail($user->email), | ||
['role' => 'member'] | ||
|
@@ -131,10 +156,24 @@ public function run() | |
]) | ||
->withPersonalTeam() | ||
->create(); | ||
|
||
if (! app()->isProduction()) { | ||
$this->createUserlogs($user); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// ----------------------------------------------------------------------------------- | ||
protected function createUserlogs(User $user): void | ||
{ | ||
for ($i = 1; $i <= rand(20, 200); $i++) { | ||
Userlog::factory([ | ||
'user_id' => $user->id, | ||
])->create(); | ||
} | ||
} | ||
|
||
// ----------------------------------------------------------------------------------- | ||
protected function createTeamPersonal(User $user, string $suffix = "'s TEAM", ?string $description = null): void | ||
{ | ||
|