Skip to content

Commit

Permalink
cleanup 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartinoscar committed Oct 18, 2024
1 parent f1f989f commit a883741
Show file tree
Hide file tree
Showing 21 changed files with 2,383 additions and 2,368 deletions.
4 changes: 2 additions & 2 deletions app/Filament/Pages/Installer/Steps/AdminUserStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AdminUserStep
public static function make(PanelInstaller $installer): Step
{
return Step::make('user')
->afterValidation(fn () => $installer->createAdminUser())
->label('Admin User')
->schema([
TextInput::make('user.email')
Expand All @@ -27,7 +28,6 @@ public static function make(PanelInstaller $installer): Step
->required()
->password()
->revealable(),
])
->afterValidation(fn () => $installer->createAdminUser());
]);
}
}
24 changes: 12 additions & 12 deletions app/Filament/Pages/Installer/Steps/DatabaseStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ class DatabaseStep
public static function make(PanelInstaller $installer): Step
{
return Step::make('database')
->afterValidation(function (Get $get) use ($installer) {
$driver = $get('env_general.DB_CONNECTION');

if (!self::testConnection($driver, $get('env_database.DB_HOST'), $get('env_database.DB_PORT'), $get('env_database.DB_DATABASE'), $get('env_database.DB_USERNAME'), $get('env_database.DB_PASSWORD'))) {
throw new Halt('Database connection failed');
}

$installer->writeToEnv('env_database');

$installer->runMigrations($driver);
})
->label('Database')
->columns()
->schema([
Expand Down Expand Up @@ -58,18 +69,7 @@ public static function make(PanelInstaller $installer): Step
->revealable()
->default(env('DB_PASSWORD'))
->hidden(fn (Get $get) => $get('env_general.DB_CONNECTION') === 'sqlite'),
])
->afterValidation(function (Get $get) use ($installer) {
$driver = $get('env_general.DB_CONNECTION');

if (!self::testConnection($driver, $get('env_database.DB_HOST'), $get('env_database.DB_PORT'), $get('env_database.DB_DATABASE'), $get('env_database.DB_USERNAME'), $get('env_database.DB_PASSWORD'))) {
throw new Halt('Database connection failed');
}

$installer->writeToEnv('env_database');

$installer->runMigrations($driver);
});
]);
}

private static function testConnection(string $driver, $host, $port, $database, $username, $password): bool
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Pages/Installer/Steps/EnvironmentStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class EnvironmentStep
public static function make(PanelInstaller $installer): Step
{
return Step::make('environment')
->afterValidation(fn () => $installer->writeToEnv('env_general'))
->label('Environment')
->columns()
->schema([
Expand Down Expand Up @@ -92,7 +93,6 @@ public static function make(PanelInstaller $installer): Step
->inline()
->options(self::DATABASE_DRIVERS)
->default(config('database.default', 'sqlite')),
])
->afterValidation(fn () => $installer->writeToEnv('env_general'));
]);
}
}
16 changes: 8 additions & 8 deletions app/Filament/Pages/Installer/Steps/RedisStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class RedisStep
public static function make(PanelInstaller $installer): Step
{
return Step::make('redis')
->afterValidation(function (Get $get) use ($installer) {
if (!self::testConnection($get('env_redis.REDIS_HOST'), $get('env_redis.REDIS_PORT'), $get('env_redis.REDIS_USERNAME'), $get('env_redis.REDIS_PASSWORD'))) {
throw new Halt('Redis connection failed');
}

$installer->writeToEnv('env_redis');
})
->label('Redis')
->columns()
->schema([
Expand Down Expand Up @@ -46,14 +53,7 @@ public static function make(PanelInstaller $installer): Step
->password()
->revealable()
->default(config('database.redis.default.password')),
])
->afterValidation(function (Get $get) use ($installer) {
if (!self::testConnection($get('env_redis.REDIS_HOST'), $get('env_redis.REDIS_PORT'), $get('env_redis.REDIS_USERNAME'), $get('env_redis.REDIS_PASSWORD'))) {
throw new Halt('Redis connection failed');
}

$installer->writeToEnv('env_redis');
});
]);
}

private static function testConnection($host, $port, $username, $password): bool
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Pages/Installer/Steps/RequirementsStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public static function make(): Step
]);

return Step::make('requirements')
->label('Server Requirements')
->schema($fields)
->afterValidation(function () use ($correctPhpVersion, $allExtensionsInstalled, $correctFolderPermissions) {
if (!$correctPhpVersion || !$allExtensionsInstalled || !$correctFolderPermissions) {
Notification::make()
Expand All @@ -84,6 +82,8 @@ public static function make(): Step

throw new Halt('Some requirements are missing');
}
});
})
->label('Server Requirements')
->schema($fields);
}
}
5 changes: 0 additions & 5 deletions app/Filament/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ class Settings extends Page implements HasForms

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public static function canAccess(): bool
{
return auth()->user()->can('view settings');
Expand Down
Loading

0 comments on commit a883741

Please sign in to comment.