Files
mytodos/database/seeders/BaseDatabaseSeeder.php
T
ecdown 177f122c10
tests / ci (push) Canceled after 0s
added roles and organizations
2026-10-15 20:59:32 -07:00

38 lines
1.0 KiB
PHP

<?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
{
$admin = User::updateOrCreate(
['email' => config('admin.email')],
[
'name' => config('admin.name'),
'password' => config('admin.password'),
'is_admin' => true,
],
);
// 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();
}
// Grandfather the admin so a fresh install is usable before any Stripe
// price is configured.
$admin->currentOrganization()->first()?->forceFill([
'lifetime_access' => true,
])->save();
}
}