38 lines
1.0 KiB
PHP
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();
|
|
}
|
|
}
|