lasthourcloud/database/seeders/InstanceSettingsSeeder.php

46 lines
1.4 KiB
PHP
Raw Normal View History

2023-04-25 07:38:05 +00:00
<?php
namespace Database\Seeders;
use App\Models\InstanceSettings;
use Illuminate\Database\Seeder;
2023-06-14 07:03:25 +00:00
use Illuminate\Support\Facades\Process;
2023-04-25 07:38:05 +00:00
class InstanceSettingsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
InstanceSettings::create([
'id' => 0,
'is_registration_enabled' => true,
2023-08-23 14:40:59 +00:00
'is_resale_license_active' => true,
'smtp_enabled' => true,
'smtp_host' => 'coolify-mail',
'smtp_port' => 1025,
'smtp_from_address' => 'hi@localhost.com',
'smtp_from_name' => 'Coolify',
2023-04-25 07:38:05 +00:00
]);
2023-06-14 07:03:25 +00:00
try {
$ipv4 = Process::run('curl -4s https://ifconfig.io')->output();
$ipv4 = trim($ipv4);
$ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
$settings = InstanceSettings::get();
if (is_null($settings->public_ipv4) && $ipv4) {
$settings->update(['public_ipv4' => $ipv4]);
}
$ipv6 = Process::run('curl -6s https://ifconfig.io')->output();
$ipv6 = trim($ipv6);
$ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP);
$settings = InstanceSettings::get();
if (is_null($settings->public_ipv6) && $ipv6) {
$settings->update(['public_ipv6' => $ipv6]);
}
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
2023-06-14 07:03:25 +00:00
echo "Error: {$e->getMessage()}\n";
}
2023-04-25 07:38:05 +00:00
}
2023-08-11 18:48:52 +00:00
}