Files
mytodos/database/seeders/BaseDatabaseSeeder.php
T

38 lines
1.0 KiB
PHP
Raw Normal View History

2026-09-17 23:01:26 -07:00
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class BaseDatabaseSeeder extends Seeder
{
/**
* Seed the application's base data.
*/
public function run(): void
{
2026-10-04 20:34:19 -07:00
$admin = User::updateOrCreate(
2026-09-17 23:01:26 -07:00
['email' => config('admin.email')],
[
'name' => config('admin.name'),
'password' => config('admin.password'),
'is_admin' => true,
],
);
2026-10-04 20:34:19 -07:00
2026-10-15 20:59:32 -07:00
// The organization is created by the model's created hook, which is
// silenced while run under a parent seeder using WithoutModelEvents,
// so create one here when needed.
if ($admin->currentOrganization()->first() === null) {
$admin->createPersonalOrganization();
}
2026-10-04 20:34:19 -07:00
// Grandfather the admin so a fresh install is usable before any Stripe
2026-10-15 20:59:32 -07:00
// price is configured.
2026-10-04 20:34:19 -07:00
$admin->currentOrganization()->first()?->forceFill([
'lifetime_access' => true,
])->save();
2026-09-17 23:01:26 -07:00
}
}