Skip to content

Commit 2296c73

Browse files
authored
Config updates (#72)
* Add seed email addresses to app config * Remove unused ENV values
1 parent 2b148ab commit 2296c73

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

.env.example

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ APP_URL=http://laravel-inertia-template.test
77

88
BCRYPT_ROUNDS=12
99

10-
SEED_SUPER_ADMIN_EMAIL=super@laravel-inertia-template.test
11-
SEED_ADMIN_EMAIL=admin@laravel-inertia-template.test
12-
SEED_USER_EMAIL=user@laravel-inertia-template.test
13-
1410
LOG_CHANNEL=stack
1511
LOG_STACK=single
1612
LOG_DEPRECATIONS_CHANNEL=null
@@ -30,7 +26,6 @@ SESSION_PATH=/
3026
SESSION_DOMAIN=null
3127

3228
CACHE_STORE=database
33-
CACHE_PREFIX=
3429

3530
BROADCAST_CONNECTION=log
3631
FILESYSTEM_DISK=local

.env.testing

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ APP_URL=http://laravel-inertia-template.test
77

88
BCRYPT_ROUNDS=4
99

10-
SEED_SUPER_ADMIN_EMAIL=super@laravel-inertia-template.test
11-
SEED_ADMIN_EMAIL=admin@laravel-inertia-template.test
12-
SEED_USER_EMAIL=user@laravel-inertia-template.test
13-
1410
LOG_CHANNEL=stack
1511
LOG_STACK=single
1612
LOG_DEPRECATIONS_CHANNEL=null

app/Http/Controllers/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function show(Request $request)
1313
$isProd = \app()->environment('production');
1414

1515
return \inertia('Login/Show', [
16-
'email' => ! $isProd ? \env('SEED_SUPER_ADMIN_EMAIL') : '',
16+
'email' => ! $isProd ? \config('app.seed.emails.super', '') : '',
1717
'password' => ! $isProd ? '12345' : '',
1818
'remember' => ! $isProd ? true : false,
1919
'redirect' => $request->query('redirect', ''),

config/app.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
return [
44

5+
'seed' => [
6+
'emails' => [
7+
'super' => env('SEED_SUPER_ADMIN_EMAIL', 'super@laravel-inertia-template.test'),
8+
'admin' => env('SEED_ADMIN_EMAIL', 'admin@laravel-inertia-template.test'),
9+
'user' => env('SEED_USER_EMAIL', 'user@laravel-inertia-template.test'),
10+
],
11+
],
12+
513
/*
614
|--------------------------------------------------------------------------
715
| Application Name

database/factories/UserFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function superAdmin(?string $email = null)
3535
{
3636
return $this
3737
->state(fn (array $attributes) => [
38-
'email' => $email ?: \env('SEED_SUPER_ADMIN_EMAIL'),
38+
'email' => $email ?: \config('app.seed.emails.super'),
3939
])
4040
->afterCreating(function (User $user) {
4141
$user->assignRole(Role::SUPER_ADMIN->value);
@@ -46,7 +46,7 @@ public function admin(?string $email = null)
4646
{
4747
return $this
4848
->state(fn (array $attributes) => [
49-
'email' => $email ?: \env('SEED_ADMIN_EMAIL'),
49+
'email' => $email ?: \config('app.seed.emails.admin'),
5050
])
5151
->afterCreating(function (User $user) {
5252
$user->assignRole(Role::ADMIN->value);
@@ -57,7 +57,7 @@ public function user(?string $email = null)
5757
{
5858
return $this
5959
->state(fn (array $attributes) => [
60-
'email' => $email ?: \env('SEED_USER_EMAIL'),
60+
'email' => $email ?: \config('app.seed.emails.user'),
6161
])
6262
->afterCreating(function (User $user) {
6363
$user->assignRole(Role::USER->value);

tests/Pest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555

5656
function superAdminUser()
5757
{
58-
return User::whereEmail(env('SEED_SUPER_ADMIN_EMAIL'))->first();
58+
return User::whereEmail(\config('app.seed.emails.super'))->first();
5959
}
6060

6161
function adminUser()
6262
{
63-
return User::whereEmail(env('SEED_ADMIN_EMAIL'))->first();
63+
return User::whereEmail(\config('app.seed.emails.admin'))->first();
6464
}

0 commit comments

Comments
 (0)