From 25168debc0a669eb62c3c385258fd515e150ccb8 Mon Sep 17 00:00:00 2001 From: Inext68 Date: Wed, 3 Jun 2026 11:18:20 +0200 Subject: [PATCH] 1.0.4 - fix instal.php --- app/Models/AppSetting.php | 33 +++---- ...05_15_000001_create_app_settings_table.php | 46 +++++++++ ...6_000001_add_logo_path_to_app_settings.php | 19 +++- ..._000002_add_app_config_to_app_settings.php | 24 +++-- ..._add_documenti_storage_to_app_settings.php | 19 +++- ...55_add_backup_settings_to_app_settings.php | 34 +++++-- .../a54cb906b71ecddfe8edf55b3671046a.php | 94 ++++++------------- 7 files changed, 164 insertions(+), 105 deletions(-) create mode 100644 database/migrations/2026_05_15_000001_create_app_settings_table.php diff --git a/app/Models/AppSetting.php b/app/Models/AppSetting.php index 0f72d99f..cc007014 100644 --- a/app/Models/AppSetting.php +++ b/app/Models/AppSetting.php @@ -1,31 +1,23 @@ 'boolean', 'backup_auto_enabled' => 'boolean', 'backup_auto_hour' => 'integer', + 'show_version' => 'boolean', ]; } - public static function getSetting(string $key, $default = null) + public static function getSetting(string $key, mixed $default = null): mixed { + if (!Schema::hasTable('app_settings')) { + return $default; + } + $setting = self::first(); return $setting?->{$key} ?? $default; } diff --git a/database/migrations/2026_05_15_000001_create_app_settings_table.php b/database/migrations/2026_05_15_000001_create_app_settings_table.php new file mode 100644 index 00000000..b1c45eb1 --- /dev/null +++ b/database/migrations/2026_05_15_000001_create_app_settings_table.php @@ -0,0 +1,46 @@ +id(); + $table->string('nome_applicazione')->nullable(); + $table->string('nome_organizzazione')->nullable(); + $table->string('logo')->nullable(); + $table->string('logo_small')->nullable(); + $table->string('logo_path')->nullable(); + $table->string('logo_small_path')->nullable(); + $table->string('footer_text')->nullable(); + $table->string('app_version')->nullable(); + $table->string('dashboard_welcome')->nullable(); + $table->boolean('show_version')->default(false); + $table->string('documenti_storage_disk')->default('local'); + $table->string('documenti_storage_path')->default('documenti'); + $table->string('backup_path')->default('backups'); + $table->integer('backup_retention_days')->default(30); + $table->boolean('backup_include_files')->default(true); + $table->boolean('backup_include_env')->default(true); + $table->boolean('backup_auto_enabled')->default(false); + $table->string('backup_auto_frequency', 20)->default('daily'); + $table->integer('backup_auto_hour')->default(3); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('app_settings'); + } +}; diff --git a/database/migrations/2026_05_16_000001_add_logo_path_to_app_settings.php b/database/migrations/2026_05_16_000001_add_logo_path_to_app_settings.php index 858aca2a..59f43f72 100644 --- a/database/migrations/2026_05_16_000001_add_logo_path_to_app_settings.php +++ b/database/migrations/2026_05_16_000001_add_logo_path_to_app_settings.php @@ -8,10 +8,21 @@ return new class extends Migration { public function up(): void { - Schema::table('app_settings', function (Blueprint $table) { - $table->string('logo_path')->nullable()->after('logo'); - $table->string('logo_small_path')->nullable()->after('logo_small'); - }); + if (!Schema::hasTable('app_settings')) { + return; + } + + if (!Schema::hasColumn('app_settings', 'logo_path')) { + Schema::table('app_settings', function (Blueprint $table) { + $table->string('logo_path')->nullable()->after('logo'); + }); + } + + if (!Schema::hasColumn('app_settings', 'logo_small_path')) { + Schema::table('app_settings', function (Blueprint $table) { + $table->string('logo_small_path')->nullable()->after('logo_small'); + }); + } } public function down(): void diff --git a/database/migrations/2026_05_16_000002_add_app_config_to_app_settings.php b/database/migrations/2026_05_16_000002_add_app_config_to_app_settings.php index abd60712..7e0c8a9c 100644 --- a/database/migrations/2026_05_16_000002_add_app_config_to_app_settings.php +++ b/database/migrations/2026_05_16_000002_add_app_config_to_app_settings.php @@ -8,12 +8,24 @@ return new class extends Migration { public function up(): void { - Schema::table('app_settings', function (Blueprint $table) { - $table->string('footer_text')->nullable()->after('nome_organizzazione'); - $table->string('app_version')->nullable()->after('footer_text'); - $table->string('dashboard_welcome')->nullable()->after('app_version'); - $table->boolean('show_version')->default(false)->after('dashboard_welcome'); - }); + if (!Schema::hasTable('app_settings')) { + return; + } + + $columns = ['footer_text', 'app_version', 'dashboard_welcome', 'show_version']; + + foreach ($columns as $column) { + if (!Schema::hasColumn('app_settings', $column)) { + Schema::table('app_settings', function (Blueprint $table) use ($column) { + match ($column) { + 'footer_text' => $table->string('footer_text')->nullable()->after('nome_organizzazione'), + 'app_version' => $table->string('app_version')->nullable()->after('footer_text'), + 'dashboard_welcome' => $table->string('dashboard_welcome')->nullable()->after('app_version'), + 'show_version' => $table->boolean('show_version')->default(false)->after('dashboard_welcome'), + }; + }); + } + } } public function down(): void diff --git a/database/migrations/2026_05_27_000003_add_documenti_storage_to_app_settings.php b/database/migrations/2026_05_27_000003_add_documenti_storage_to_app_settings.php index 9c8cc5ca..427de52b 100644 --- a/database/migrations/2026_05_27_000003_add_documenti_storage_to_app_settings.php +++ b/database/migrations/2026_05_27_000003_add_documenti_storage_to_app_settings.php @@ -8,10 +8,21 @@ return new class extends Migration { public function up(): void { - Schema::table('app_settings', function (Blueprint $table) { - $table->string('documenti_storage_disk')->default('local')->after('show_version'); - $table->string('documenti_storage_path')->default('documenti')->after('documenti_storage_disk'); - }); + if (!Schema::hasTable('app_settings')) { + return; + } + + if (!Schema::hasColumn('app_settings', 'documenti_storage_disk')) { + Schema::table('app_settings', function (Blueprint $table) { + $table->string('documenti_storage_disk')->default('local')->after('show_version'); + }); + } + + if (!Schema::hasColumn('app_settings', 'documenti_storage_path')) { + Schema::table('app_settings', function (Blueprint $table) { + $table->string('documenti_storage_path')->default('documenti')->after('documenti_storage_disk'); + }); + } } public function down(): void diff --git a/database/migrations/2026_06_01_100155_add_backup_settings_to_app_settings.php b/database/migrations/2026_06_01_100155_add_backup_settings_to_app_settings.php index 634d1010..b2a45cd5 100644 --- a/database/migrations/2026_06_01_100155_add_backup_settings_to_app_settings.php +++ b/database/migrations/2026_06_01_100155_add_backup_settings_to_app_settings.php @@ -10,15 +10,31 @@ return new class extends Migration { public function up(): void { - Schema::table('app_settings', function (Blueprint $table) { - $table->string('backup_path')->default('backups')->after('show_version'); - $table->integer('backup_retention_days')->default(30)->after('backup_path'); - $table->boolean('backup_include_files')->default(true)->after('backup_retention_days'); - $table->boolean('backup_include_env')->default(true)->after('backup_include_files'); - $table->boolean('backup_auto_enabled')->default(false)->after('backup_include_env'); - $table->string('backup_auto_frequency', 20)->default('daily')->after('backup_auto_enabled'); - $table->integer('backup_auto_hour')->default(3)->after('backup_auto_frequency'); - }); + if (!Schema::hasTable('app_settings')) { + return; + } + + $columns = [ + 'backup_path' => ['type' => 'string', 'default' => 'backups'], + 'backup_retention_days' => ['type' => 'integer', 'default' => 30], + 'backup_include_files' => ['type' => 'boolean', 'default' => true], + 'backup_include_env' => ['type' => 'boolean', 'default' => true], + 'backup_auto_enabled' => ['type' => 'boolean', 'default' => false], + 'backup_auto_frequency' => ['type' => 'string', 'length' => 20, 'default' => 'daily'], + 'backup_auto_hour' => ['type' => 'integer', 'default' => 3], + ]; + + foreach ($columns as $column => $config) { + if (!Schema::hasColumn('app_settings', $column)) { + Schema::table('app_settings', function (Blueprint $table) use ($column, $config) { + match ($config['type']) { + 'string' => $table->string($column, $config['length'] ?? 255)->default($config['default'])->after('show_version'), + 'integer' => $table->integer($column)->default($config['default'])->after('show_version'), + 'boolean' => $table->boolean($column)->default($config['default'])->after('show_version'), + }; + }); + } + } } public function down(): void diff --git a/storage/framework/views/a54cb906b71ecddfe8edf55b3671046a.php b/storage/framework/views/a54cb906b71ecddfe8edf55b3671046a.php index 36ce38e7..fedcf501 100755 --- a/storage/framework/views/a54cb906b71ecddfe8edf55b3671046a.php +++ b/storage/framework/views/a54cb906b71ecddfe8edf55b3671046a.php @@ -773,7 +773,7 @@ echo 'Utente creato con successo!';
Panoramica
-

L'installazione avviene tramite comandi Artisan da terminale. Non esiste un wizard web interattivo. Supporta due modalita:

+

L'installazione avviene tramite l'interattivo install.php che guida passo-passo. Supporta due modalita:

@@ -827,19 +827,37 @@ git clone <URL_REPOSITORY> glastree # Opzione B — ZIP (se non hai git) # unzip /percorso/del/glastree.zip -d glastree -cd glastree -composer install --no-dev --optimize-autoloader -npm ci && npm run build -
- - Se non hai accesso a npm, puoi saltare il build. L'interfaccia usera comunque AdminLTE via CDN. +cd glastree + +
Passo 3: Eseguire l'installer
+

Lancerai l'installer interattivo che ti guidera attraverso tutte le fasi:

+
php install.php
+

L'installer ti chiedera:

+
    +
  1. Modalità: Fresh Install (Apache/Docker) o Restore da Backup
  2. +
  3. Parametri generali: nome sito, amministratore (nome, email, password), URL pubblico
  4. +
  5. Database: MySQL (host, porta, nome, utente, password) o SQLite
  6. +
+

L'installer esegue automaticamente:

+
    +
  • Generazione .env e APP_KEY
  • +
  • Creazione del database
  • +
  • composer install e registrazione pacchetti
  • +
  • Migration e seed dei dati di base
  • +
  • Creazione dell'utente amministratore
  • +
  • Compilazione asset frontend (se npm disponibile)
  • +
  • Impostazione permessi cartelle
  • +
+
+
Docker
+

Se scegli la modalita Docker, l'installer builda l'immagine, avvia i container e crea l'admin all'interno del container.

+
+
+
Restore da Backup
+

Se scegli Restore, l'installer ti chiedera il percorso del file ZIP di backup, ripristinera il database, i file e la configurazione.

-
Passo 3: Permessi cartelle
-
sudo chown -R www-data:www-data storage bootstrap/cache
-sudo chmod -R 775 storage bootstrap/cache
- -
Passo 4: Configurare Apache
+
Passo 4: Configurare Apache (solo modalita Fresh Install)
sudo tee /etc/apache2/sites-available/glastree.conf <<APACHE
 <VirtualHost *:80>
     ServerName glastree.esempio.it
@@ -859,58 +877,6 @@ APACHE
 sudo a2dissite 000-default.conf
 sudo a2ensite glastree.conf
 sudo systemctl reload apache2
- -
Passo 5: Configurare l'ambiente
-
# Copia il file di configurazione di esempio
-cp .env.example .env
-
-# Genera la chiave di crittografia (obbligatorio)
-php artisan key:generate
-
-# Modifica .env con i parametri del tuo database:
-# nano .env
-# DB_DATABASE=glastree
-# DB_USERNAME=glastree
-# DB_PASSWORD=la_tua_password
- -
Passo 6: Eseguire l'installazione
-

Scegli la modalita in base alle tue esigenze:

- -
Fresh Install
-
# Esegui migration e seed dei dati di base
-php artisan migrate --seed
-
-# Crea il collegamento storage
-php artisan storage:link
-
-# Crea l'utente amministratore
-php artisan tinker --execute="
-\$u = new \App\Models\User;
-\$u->name = 'Admin';
-\$u->email = 'admin@esempio.it';
-\$u->password = bcrypt('password_sicura');
-\$u->save();
-"
- -
-
Dopo l'installazione
-

Accedi con le credenziali create, vai in Impostazioni → Generali per configurare nome app, logo e parametri email.

-
- -
Restore da Backup
-
# Crea il database e importa il backup
-# mysql -u root -p glastree < database.sql
-
-# Ripristina i file dei documenti
-# tar -xzf storage.tar.gz -C storage/
-
-# Rigenera APP_KEY (invalida dati criptati esistenti!)
-php artisan key:generate
-
-# Crea il collegamento storage
-php artisan storage:link
- -
Importante: Il restore da backup richiede che tu abbia un file ZIP generato dalla pagina Admin → Backup del server originale. Estrai manualmente il contenuto seguendo la struttura del progetto.