glastree_on_gitea
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nome');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('telefono')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->boolean('attivo')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('diocesi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nome');
|
||||
$table->string('regione')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('comuni', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nome');
|
||||
$table->string('codice_istat', 10)->nullable();
|
||||
$table->string('cap')->nullable();
|
||||
$table->string('sigla_provincia', 2)->nullable();
|
||||
$table->string('regione')->nullable();
|
||||
$table->float('latitudine')->nullable();
|
||||
$table->float('longitudine')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('nome');
|
||||
$table->index('sigla_provincia');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('comuni');
|
||||
Schema::dropIfExists('diocesi');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('individui', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->string('codice_id', 5)->unique();
|
||||
$table->string('cognome');
|
||||
$table->string('nome');
|
||||
$table->date('data_nascita')->nullable();
|
||||
$table->string('indirizzo')->nullable();
|
||||
$table->string('cap', 10)->nullable();
|
||||
$table->string('città')->nullable();
|
||||
$table->string('sigla_provincia', 2)->nullable();
|
||||
$table->enum('genere', ['M', 'F'])->nullable();
|
||||
$table->enum('tipo_documento', ['carta_identita', 'patente'])->nullable();
|
||||
$table->date('scadenza_documento')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->string('avatar_path')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
$table->index('codice_id');
|
||||
$table->index('cognome');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('individui');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contatti', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
|
||||
$table->enum('tipo', ['telefono', 'cellulare', 'email', 'fax', 'web', 'telegram', 'whatsapp', 'altro']);
|
||||
$table->string('valore');
|
||||
$table->string('etichetta')->nullable();
|
||||
$table->boolean('is_primary')->default(false);
|
||||
$table->timestamps();
|
||||
$table->index('individuo_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contatti');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gruppi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->foreignId('parent_id')->nullable()->constrained('gruppi')->onDelete('set null');
|
||||
$table->foreignId('diocesi_id')->nullable()->constrained('diocesi')->onDelete('set null');
|
||||
$table->foreignId('responsabile_id')->nullable()->constrained('individui')->onDelete('set null');
|
||||
$table->string('nome');
|
||||
$table->text('descrizione')->nullable();
|
||||
$table->string('indirizzo_incontro')->nullable();
|
||||
$table->string('cap_incontro', 10)->nullable();
|
||||
$table->string('città_incontro')->nullable();
|
||||
$table->string('sigla_provincia_incontro', 2)->nullable();
|
||||
$table->string('mappa_posizione')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
$table->index('parent_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('gruppi');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade');
|
||||
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
|
||||
$table->string('ruolo_nel_gruppo')->nullable();
|
||||
$table->date('data_adesione')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['gruppo_id', 'individuo_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('gruppo_individuo');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('eventi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->string('nome_evento');
|
||||
$table->string('tipo_evento')->nullable();
|
||||
$table->enum('tipo_recorrenza', ['singolo', 'ricorrente'])->default('singolo');
|
||||
$table->unsignedTinyInteger('giorno_settimana')->nullable();
|
||||
$table->time('ora_inizio')->nullable();
|
||||
$table->date('data_specifica')->nullable();
|
||||
$table->unsignedInteger('durata_minuti')->nullable();
|
||||
$table->text('descrizione')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
});
|
||||
|
||||
Schema::create('eventi_gruppi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
|
||||
$table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('eventi_responsabili', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
|
||||
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('eventi_responsabili');
|
||||
Schema::dropIfExists('eventi_gruppi');
|
||||
Schema::dropIfExists('eventi');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('documenti', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->string('nome_file');
|
||||
$table->string('file_path');
|
||||
$table->string('tipo')->nullable();
|
||||
$table->enum('tipologia', ['avatar', 'galleria', 'documento', 'statuto', 'altro'])->default('documento');
|
||||
$table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione'])->default('gruppo');
|
||||
$table->unsignedBigInteger('visibilita_target_id')->nullable();
|
||||
$table->string('visibilita_target_type')->nullable();
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->unsignedBigInteger('dimensione')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('documenti');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('mailing_lists', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->string('nome');
|
||||
$table->text('descrizione')->nullable();
|
||||
$table->boolean('attiva')->default(true);
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
});
|
||||
|
||||
Schema::create('mailing_contacts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mailing_list_id')->constrained('mailing_lists')->onDelete('cascade');
|
||||
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
|
||||
$table->boolean('opt_in')->default(true);
|
||||
$table->dateTime('opt_in_data')->nullable();
|
||||
$table->dateTime('opt_out_data')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['mailing_list_id', 'individuo_id']);
|
||||
});
|
||||
|
||||
Schema::create('mailing_messaggi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->foreignId('mailing_list_id')->nullable()->constrained('mailing_lists')->onDelete('set null');
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->string('oggetto');
|
||||
$table->text('corpo')->nullable();
|
||||
$table->enum('canale', ['email', 'telegram'])->default('email');
|
||||
$table->enum('stato', ['bozza', 'in_coda', 'inviato', 'fallito'])->default('bozza');
|
||||
$table->timestamp('inviato_al')->nullable();
|
||||
$table->integer('totale_destinatari')->default(0);
|
||||
$table->integer('invii_ok')->default(0);
|
||||
$table->integer('invii_falliti')->default(0);
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mailing_messaggi');
|
||||
Schema::dropIfExists('mailing_contacts');
|
||||
Schema::dropIfExists('mailing_lists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notifiche', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->string('tipo');
|
||||
$table->string('titolo');
|
||||
$table->text('messaggio');
|
||||
$table->string('link')->nullable();
|
||||
$table->boolean('is_read')->default(false);
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifiche');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->boolean('is_admin')->default(false);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->index('tenant_id');
|
||||
$table->index('email');
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
Schema::dropIfExists('cache');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('individui', function (Blueprint $table) {
|
||||
$table->string('numero_documento', 50)->nullable()->after('tipo_documento');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('individui', function (Blueprint $table) {
|
||||
$table->dropColumn('numero_documento');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('individui', function (Blueprint $table) {
|
||||
$table->dropColumn('telegram_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('individui', function (Blueprint $table) {
|
||||
$table->string('telegram_id', 100)->nullable()->after('note');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->string('giorno_mese')->nullable()->after('giorno_settimana');
|
||||
$table->string('mesi_recorrenza')->nullable()->after('giorno_mese');
|
||||
$table->string('mese_annuale')->nullable()->after('mesi_recorrenza');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->dropColumn('giorno_mese');
|
||||
$table->dropColumn('mesi_recorrenza');
|
||||
$table->dropColumn('mese_annuale');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('occorrenza_mese')->nullable()->after('giorno_mese');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->dropColumn('occorrenza_mese');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->enum('tipo_recorrenza', ['singolo', 'settimanale', 'mensile', 'annuale', 'altro'])->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->enum('tipo_recorrenza', ['singolo', 'ricorrente'])->default('singolo')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('eventi_documenti', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
|
||||
$table->foreignId('documento_id')->constrained('documenti')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('eventi_documenti');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione', 'evento'])->default('gruppo')->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione'])->default('gruppo')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('set null')->after('tenant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('viste_report', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->string('nome');
|
||||
$table->string('tipo'); // individui, gruppi, documenti, eventi
|
||||
$table->json('colonne_visibili')->nullable();
|
||||
$table->json('colonne_ordinamento')->nullable(); // [['colonna', 'direzione']]
|
||||
$table->json('filtri')->nullable(); // [['colonna', 'operatore', 'valore']]
|
||||
$table->string('ricerca')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('tipo');
|
||||
$table->index('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('viste_report');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('viste_report', function (Blueprint $table) {
|
||||
$table->boolean('is_default')->default(false)->after('nome');
|
||||
$table->index('is_default');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('viste_report', function (Blueprint $table) {
|
||||
$table->dropColumn('is_default');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mailing_lists', function (Blueprint $table) {
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('set null')->after('tenant_id');
|
||||
$table->index('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mailing_lists', function (Blueprint $table) {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropIndex(['user_id']);
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tipologie_documenti', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nome', 50)->unique();
|
||||
$table->string('descrizione', 255)->nullable();
|
||||
$table->integer('ordine')->default(0);
|
||||
$table->boolean('attiva')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$defaultTipologie = ['avatar', 'galleria', 'documento', 'statuto', 'altro'];
|
||||
foreach ($defaultTipologie as $i => $nome) {
|
||||
DB::table('tipologie_documenti')->insert([
|
||||
'nome' => $nome,
|
||||
'descrizione' => ucfirst($nome),
|
||||
'ordine' => $i,
|
||||
'attiva' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tipologie_documenti');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->json('permissions')->nullable()->after('is_admin');
|
||||
});
|
||||
|
||||
Schema::create('activity_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('action');
|
||||
$table->string('module');
|
||||
$table->string('description')->nullable();
|
||||
$table->json('details')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
|
||||
$table->index(['user_id', 'module']);
|
||||
$table->index(['created_at']);
|
||||
$table->index(['action']);
|
||||
});
|
||||
|
||||
Schema::create('role_presets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50)->unique();
|
||||
$table->string('description')->nullable();
|
||||
$table->json('permissions');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
Schema::dropIfExists('role_presets');
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('permissions');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('users', 'status')) {
|
||||
$table->string('status', 20)->default('active')->after('is_admin');
|
||||
}
|
||||
if (!Schema::hasColumn('users', 'permissions')) {
|
||||
$table->json('permissions')->nullable()->after('status');
|
||||
}
|
||||
if (!Schema::hasColumn('users', 'role_preset_id')) {
|
||||
$table->unsignedBigInteger('role_preset_id')->nullable()->after('permissions');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('users', 'status')) {
|
||||
$table->dropColumn('status');
|
||||
}
|
||||
if (Schema::hasColumn('users', 'permissions')) {
|
||||
$table->dropColumn('permissions');
|
||||
}
|
||||
if (Schema::hasColumn('users', 'role_preset_id')) {
|
||||
$table->dropColumn('role_preset_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
$table->id(); // permission id
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->id(); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['roles']);
|
||||
Schema::dropIfExists($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('imap_host')->nullable();
|
||||
$table->integer('imap_port')->nullable()->default(993);
|
||||
$table->string('imap_encryption')->nullable()->default('ssl');
|
||||
$table->string('imap_username')->nullable();
|
||||
$table->string('imap_password')->nullable();
|
||||
$table->string('smtp_host')->nullable();
|
||||
$table->integer('smtp_port')->nullable()->default(587);
|
||||
$table->string('smtp_encryption')->nullable()->default('tls');
|
||||
$table->string('smtp_username')->nullable();
|
||||
$table->string('smtp_password')->nullable();
|
||||
$table->string('email_address')->nullable();
|
||||
$table->string('email_name')->nullable();
|
||||
$table->string('reply_to')->nullable();
|
||||
$table->integer('sync_interval_minutes')->default(5);
|
||||
$table->timestamp('last_sync_at')->nullable();
|
||||
$table->boolean('is_active')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_folders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('imap_folder_name')->nullable();
|
||||
$table->string('type')->default('custom');
|
||||
$table->string('icon')->default('fa-folder');
|
||||
$table->string('color')->nullable();
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->boolean('is_system')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_folders');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_messages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('email_folder_id')->constrained('email_folders')->onDelete('cascade');
|
||||
$table->string('message_id')->nullable()->index();
|
||||
$table->string('subject')->nullable();
|
||||
$table->string('from_name')->nullable();
|
||||
$table->string('from_email')->nullable();
|
||||
$table->string('to_name')->nullable();
|
||||
$table->string('to_email')->nullable();
|
||||
$table->text('cc')->nullable();
|
||||
$table->text('bcc')->nullable();
|
||||
$table->longText('body_text')->nullable();
|
||||
$table->longText('body_html')->nullable();
|
||||
$table->boolean('is_read')->default(false);
|
||||
$table->boolean('is_starred')->default(false);
|
||||
$table->boolean('is_important')->default(false);
|
||||
$table->boolean('is_sent')->default(false);
|
||||
$table->boolean('is_draft')->default(false);
|
||||
$table->boolean('is_trash')->default(false);
|
||||
$table->timestamp('received_at')->nullable();
|
||||
$table->timestamp('sent_at')->nullable();
|
||||
$table->unsignedBigInteger('imap_uid')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('is_read');
|
||||
$table->index('is_starred');
|
||||
$table->index('is_sent');
|
||||
$table->index('received_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_messages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->enum('tipologia', ['avatar', 'galleria', 'documento', 'statuto', 'altro', 'email_attachment'])->default('documento')->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->enum('tipologia', ['avatar', 'galleria', 'documento', 'statuto', 'altro'])->default('documento')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('tipologie_documenti')->insert([
|
||||
'nome' => 'email_attachment',
|
||||
'descrizione' => 'Allegato email',
|
||||
'ordine' => 100,
|
||||
'attiva' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('tipologie_documenti')->where('nome', 'email_attachment')->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('email_message_id')->constrained('email_messages')->onDelete('cascade');
|
||||
$table->string('filename');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->bigInteger('size')->default(0);
|
||||
$table->string('file_path');
|
||||
$table->boolean('is_saved_to_documenti')->default(false);
|
||||
$table->foreignId('documenti_id')->nullable()->constrained('documenti')->onDelete('set null');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_attachments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
$table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione'])->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('documenti', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ruoli', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nome', 50)->unique();
|
||||
$table->string('descrizione', 255)->nullable();
|
||||
$table->integer('ordine')->default(0);
|
||||
$table->boolean('attiva')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$defaultRuoli = [
|
||||
['nome' => 'Membro', 'descrizione' => 'Membro del gruppo'],
|
||||
['nome' => 'Catechista', 'descrizione' => 'Catechista del gruppo'],
|
||||
['nome' => 'Animatore', 'descrizione' => 'Animatore del gruppo'],
|
||||
['nome' => 'Responsabile', 'descrizione' => 'Responsabile del gruppo'],
|
||||
['nome' => 'Vice Responsabile', 'descrizione' => 'Vice responsabile del gruppo'],
|
||||
['nome' => 'Segretario', 'descrizione' => 'Segretario del gruppo'],
|
||||
['nome' => 'Tesoriere', 'descrizione' => 'Tesoriere del gruppo'],
|
||||
];
|
||||
|
||||
foreach ($defaultRuoli as $i => $ruolo) {
|
||||
DB::table('ruoli')->insert([
|
||||
'nome' => $ruolo['nome'],
|
||||
'descrizione' => $ruolo['descrizione'],
|
||||
'ordine' => $i,
|
||||
'attiva' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('ruolo_id')->nullable()->after('ruolo_nel_gruppo');
|
||||
$table->foreign('ruolo_id')->references('id')->on('ruoli')->onDelete('set null');
|
||||
$table->index('ruolo_id');
|
||||
});
|
||||
|
||||
$ruoliMap = DB::table('ruoli')->pluck('id', 'nome')->toArray();
|
||||
|
||||
$pivotRecords = DB::table('gruppo_individuo')
|
||||
->whereNotNull('ruolo_nel_gruppo')
|
||||
->where('ruolo_nel_gruppo', '!=', '')
|
||||
->distinct()
|
||||
->pluck('ruolo_nel_gruppo');
|
||||
|
||||
foreach ($pivotRecords as $ruoloNome) {
|
||||
if (isset($ruoliMap[$ruoloNome])) {
|
||||
DB::table('gruppo_individuo')
|
||||
->where('ruolo_nel_gruppo', $ruoloNome)
|
||||
->update(['ruolo_id' => $ruoliMap[$ruoloNome]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->dropForeign(['ruolo_id']);
|
||||
$table->dropColumn('ruolo_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('ruoli');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->dropForeign(['ruolo_id']);
|
||||
$table->dropColumn('ruolo_id');
|
||||
});
|
||||
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->json('ruolo_ids')->nullable()->after('individuo_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->dropColumn('ruolo_ids');
|
||||
});
|
||||
|
||||
Schema::table('gruppo_individuo', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('ruolo_id')->nullable()->after('individuo_id');
|
||||
$table->foreign('ruolo_id')->references('id')->on('ruoli')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('gruppi', function (Blueprint $table) {
|
||||
$table->dropForeign(['responsabile_id']);
|
||||
$table->dropColumn('responsabile_id');
|
||||
});
|
||||
|
||||
Schema::table('gruppi', function (Blueprint $table) {
|
||||
$table->json('responsabile_ids')->nullable()->after('diocesi_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('gruppi', function (Blueprint $table) {
|
||||
$table->dropColumn('responsabile_ids');
|
||||
});
|
||||
|
||||
Schema::table('gruppi', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('responsabile_id')->nullable()->after('diocesi_id');
|
||||
$table->foreign('responsabile_id')->references('id')->on('individui')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->string('luogo_indirizzo', 500)->nullable()->after('note');
|
||||
$table->text('luogo_url_maps')->nullable()->after('luogo_indirizzo');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('eventi', function (Blueprint $table) {
|
||||
$table->dropColumn(['luogo_indirizzo', 'luogo_url_maps']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE documenti MODIFY COLUMN tipologia ENUM('avatar', 'galleria', 'documento', 'statuto', 'altro', 'programma', 'locandina') DEFAULT 'documento'");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE documenti MODIFY COLUMN tipologia ENUM('avatar', 'galleria', 'documento', 'statuto', 'altro') DEFAULT 'documento'");
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('app_settings', function (Blueprint $table) {
|
||||
$table->dropColumn(['logo_path', 'logo_small_path']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('app_settings', function (Blueprint $table) {
|
||||
$table->dropColumn(['footer_text', 'app_version', 'dashboard_welcome', 'show_version']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('email_settings', function (Blueprint $table) {
|
||||
$table->longText('signature')->nullable()->after('reply_to');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('email_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('signature');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('email_settings', function (Blueprint $table) {
|
||||
$table->boolean('signature_enabled')->default(true)->after('signature');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('email_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('signature_enabled');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('report_custom', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->string('nome');
|
||||
$table->text('descrizione')->nullable();
|
||||
$table->string('tipo_report');
|
||||
$table->json('config')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('report_custom');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Comune;
|
||||
|
||||
class ComuniSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$comuni = [
|
||||
['nome' => 'Roma', 'codice_istat' => '058091', 'cap' => '00100', 'sigla_provincia' => 'RM', 'regione' => 'Lazio'],
|
||||
['nome' => 'Milano', 'codice_istat' => '015146', 'cap' => '20100', 'sigla_provincia' => 'MI', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Napoli', 'codice_istat' => '063138', 'cap' => '80100', 'sigla_provincia' => 'NA', 'regione' => 'Campania'],
|
||||
['nome' => 'Torino', 'codice_istat' => '001272', 'cap' => '10100', 'sigla_provincia' => 'TO', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Palermo', 'codice_istat' => 'G273', 'cap' => '90100', 'sigla_provincia' => 'PA', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Genova', 'codice_istat' => '009969', 'cap' => '16100', 'sigla_provincia' => 'GE', 'regione' => 'Liguria'],
|
||||
['nome' => 'Bologna', 'codice_istat' => '037015', 'cap' => '40100', 'sigla_provincia' => 'BO', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Firenze', 'codice_istat' => '048017', 'cap' => '50100', 'sigla_provincia' => 'FI', 'regione' => 'Toscana'],
|
||||
['nome' => 'Bari', 'codice_istat' => 'A662', 'cap' => '70100', 'sigla_provincia' => 'BA', 'regione' => 'Puglia'],
|
||||
['nome' => 'Catania', 'codice_istat' => 'C351', 'cap' => '95100', 'sigla_provincia' => 'CT', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Venezia', 'codice_istat' => 'L736', 'cap' => '30100', 'sigla_provincia' => 'VE', 'regione' => 'Veneto'],
|
||||
['nome' => 'Verona', 'codice_istat' => 'L780', 'cap' => '37100', 'sigla_provincia' => 'VR', 'regione' => 'Veneto'],
|
||||
['nome' => 'Messina', 'codice_istat' => 'F158', 'cap' => '98100', 'sigla_provincia' => 'ME', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Padova', 'codice_istat' => 'G224', 'cap' => '35100', 'sigla_provincia' => 'PD', 'regione' => 'Veneto'],
|
||||
['nome' => 'Trieste', 'codice_istat' => 'L424', 'cap' => '34100', 'sigla_provincia' => 'TS', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Brescia', 'codice_istat' => 'B157', 'cap' => '25100', 'sigla_provincia' => 'BS', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Reggio Calabria', 'codice_istat' => 'H224', 'cap' => '89100', 'sigla_provincia' => 'RC', 'regione' => 'Calabria'],
|
||||
['nome' => 'Taranto', 'codice_istat' => 'L049', 'cap' => '74100', 'sigla_provincia' => 'TA', 'regione' => 'Puglia'],
|
||||
['nome' => 'Modena', 'codice_istat' => 'F257', 'cap' => '41100', 'sigla_provincia' => 'MO', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Parma', 'codice_istat' => 'G337', 'cap' => '43100', 'sigla_provincia' => 'PR', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Reggio Emilia', 'codice_istat' => 'H223', 'cap' => '42100', 'sigla_provincia' => 'RE', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Perugia', 'codice_istat' => 'G478', 'cap' => '06100', 'sigla_provincia' => 'PG', 'regione' => 'Umbria'],
|
||||
['nome' => 'Ravenna', 'codice_istat' => 'H199', 'cap' => '48100', 'sigla_provincia' => 'RA', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Livorno', 'codice_istat' => 'E625', 'cap' => '57100', 'sigla_provincia' => 'LI', 'regione' => 'Toscana'],
|
||||
['nome' => 'Cagliari', 'codice_istat' => 'B354', 'cap' => '09100', 'sigla_provincia' => 'CA', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Foggia', 'codice_istat' => 'D643', 'cap' => '71100', 'sigla_provincia' => 'FG', 'regione' => 'Puglia'],
|
||||
['nome' => 'Rimini', 'codice_istat' => 'H294', 'cap' => '47900', 'sigla_provincia' => 'RN', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Salerno', 'codice_istat' => 'H703', 'cap' => '84100', 'sigla_provincia' => 'SA', 'regione' => 'Campania'],
|
||||
['nome' => 'Ferrara', 'codice_istat' => 'D548', 'cap' => '44100', 'sigla_provincia' => 'FE', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Sassari', 'codice_istat' => 'I452', 'cap' => '07100', 'sigla_provincia' => 'SS', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Latina', 'codice_istat' => 'E472', 'cap' => '04100', 'sigla_provincia' => 'LT', 'regione' => 'Lazio'],
|
||||
['nome' => 'Giugliano in Campania', 'codice_istat' => 'E045', 'cap' => '80014', 'sigla_provincia' => 'NA', 'regione' => 'Campania'],
|
||||
['nome' => 'Monza', 'codice_istat' => 'F704', 'cap' => '20900', 'sigla_provincia' => 'MB', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Siracusa', 'codice_istat' => 'I754', 'cap' => '96100', 'sigla_provincia' => 'SR', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Bergamo', 'codice_istat' => 'A794', 'cap' => '24100', 'sigla_provincia' => 'BG', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Pescara', 'codice_istat' => 'G482', 'cap' => '65100', 'sigla_provincia' => 'PE', 'regione' => 'Abruzzo'],
|
||||
['nome' => 'Forlì', 'codice_istat' => 'D704', 'cap' => '47100', 'sigla_provincia' => 'FC', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Trento', 'codice_istat' => 'L378', 'cap' => '38100', 'sigla_provincia' => 'TN', 'regione' => 'Trentino-Alto Adige'],
|
||||
['nome' => 'Terni', 'codice_istat' => 'L117', 'cap' => '05100', 'sigla_provincia' => 'TR', 'regione' => 'Umbria'],
|
||||
['nome' => 'Novara', 'codice_istat' => 'F952', 'cap' => '28100', 'sigla_provincia' => 'NO', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Ancona', 'codice_istat' => 'A271', 'cap' => '60100', 'sigla_provincia' => 'AN', 'regione' => 'Marche'],
|
||||
['nome' => 'Piacenza', 'codice_istat' => 'G535', 'cap' => '29100', 'sigla_provincia' => 'PC', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Lecce', 'codice_istat' => 'E506', 'cap' => '73100', 'sigla_provincia' => 'LE', 'regione' => 'Puglia'],
|
||||
['nome' => 'Bolzano', 'codice_istat' => 'A952', 'cap' => '39100', 'sigla_provincia' => 'BZ', 'regione' => 'Trentino-Alto Adige'],
|
||||
['nome' => 'Catanzaro', 'codice_istat' => 'C352', 'cap' => '88100', 'sigla_provincia' => 'CZ', 'regione' => 'Calabria'],
|
||||
['nome' => 'Udine', 'codice_istat' => 'L483', 'cap' => '33100', 'sigla_provincia' => 'UD', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Aversa', 'codice_istat' => 'A512', 'cap' => '81031', 'sigla_provincia' => 'CE', 'regione' => 'Campania'],
|
||||
['nome' => 'Potenza', 'codice_istat' => 'G942', 'cap' => '85100', 'sigla_provincia' => 'PZ', 'regione' => 'Basilicata'],
|
||||
['nome' => 'Castellammare di Stabia', 'codice_istat' => 'C129', 'cap' => '80053', 'sigla_provincia' => 'NA', 'regione' => 'Campania'],
|
||||
['nome' => 'Afragola', 'codice_istat' => 'A064', 'cap' => '80021', 'sigla_provincia' => 'NA', 'regione' => 'Campania'],
|
||||
['nome' => 'Crotone', 'codice_istat' => 'D122', 'cap' => '88900', 'sigla_provincia' => 'KR', 'regione' => 'Calabria'],
|
||||
['nome' => 'Pavia', 'codice_istat' => 'G388', 'cap' => '27100', 'sigla_provincia' => 'PV', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Caserta', 'codice_istat' => 'B963', 'cap' => '81100', 'sigla_provincia' => 'CE', 'regione' => 'Campania'],
|
||||
['nome' => 'Salò', 'codice_istat' => 'H727', 'cap' => '25087', 'sigla_provincia' => 'BS', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Brescia', 'codice_istat' => 'B157', 'cap' => '25100', 'sigla_provincia' => 'BS', 'regione' => 'Lombardia'],
|
||||
];
|
||||
|
||||
foreach ($comuni as $c) {
|
||||
Comune::create($c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
DiocesiSeeder::class,
|
||||
ComuniSeeder::class,
|
||||
RoleSeeder::class,
|
||||
RolePresetSeeder::class,
|
||||
]);
|
||||
|
||||
$admin = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@glastree.local',
|
||||
'password' => bcrypt('password'),
|
||||
'is_admin' => true,
|
||||
'status' => 'active',
|
||||
'permissions' => [
|
||||
'individui' => 2,
|
||||
'gruppi' => 2,
|
||||
'eventi' => 2,
|
||||
'documenti' => 2,
|
||||
'mailing' => 2,
|
||||
'viste' => 2,
|
||||
],
|
||||
]);
|
||||
|
||||
$admin->role_preset_id = 1;
|
||||
$admin->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Diocesi;
|
||||
|
||||
class DiocesiSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$diocesi = [
|
||||
['nome' => 'Acqui Terme', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Afragola', 'regione' => 'Campania'],
|
||||
['nome' => 'Agrigento', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Alba', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Alessandria', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Ancona', 'regione' => 'Marche'],
|
||||
['nome' => 'Aosta', 'regione' => 'Valle d\'Aosta'],
|
||||
['nome' => 'Aquila', 'regione' => 'Abruzzo'],
|
||||
['nome' => 'Arezzo', 'regione' => 'Toscana'],
|
||||
['nome' => 'Ascoli Piceno', 'regione' => 'Marche'],
|
||||
['nome' => 'Assisi', 'regione' => 'Umbria'],
|
||||
['nome' => 'Asti', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Avellino', 'regione' => 'Campania'],
|
||||
['nome' => 'Bari', 'regione' => 'Puglia'],
|
||||
['nome' => 'Barletta', 'regione' => 'Puglia'],
|
||||
['nome' => 'Belluno', 'regione' => 'Veneto'],
|
||||
['nome' => 'Benevento', 'regione' => 'Campania'],
|
||||
['nome' => 'Bergamo', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Biella', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Bologna', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Bolzano', 'regione' => 'Trentino-Alto Adige'],
|
||||
['nome' => 'Brescia', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Brindisi', 'regione' => 'Puglia'],
|
||||
['nome' => 'Cagliari', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Caltanissetta', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Campobasso', 'regione' => 'Molise'],
|
||||
['nome' => 'Caserta', 'regione' => 'Campania'],
|
||||
['nome' => 'Cassano allo Ionio', 'regione' => 'Calabria'],
|
||||
['nome' => 'Castelvetrano', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Catania', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Catanzaro', 'regione' => 'Calabria'],
|
||||
['nome' => 'Cefalù', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Cerro al Lambro', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Cesena', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Chieti', 'regione' => 'Abruzzo'],
|
||||
['nome' => 'Civitavecchia', 'regione' => 'Lazio'],
|
||||
['nome' => 'Cosenza', 'regione' => 'Calabria'],
|
||||
['nome' => 'Cremona', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Crotone', 'regione' => 'Calabria'],
|
||||
['nome' => 'Cuneo', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Donegal', 'regione' => 'Irlanda'],
|
||||
['nome' => 'Enna', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Fano', 'regione' => 'Marche'],
|
||||
['nome' => 'Fermo', 'regione' => 'Marche'],
|
||||
['nome' => 'Ferrara', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Firenze', 'regione' => 'Toscana'],
|
||||
['nome' => 'Foggia', 'regione' => 'Puglia'],
|
||||
['nome' => 'Foligno', 'regione' => 'Umbria'],
|
||||
['nome' => 'Forlì', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Frosinone', 'regione' => 'Lazio'],
|
||||
['nome' => 'Genova', 'regione' => 'Liguria'],
|
||||
['nome' => 'Gorizia', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Grosseto', 'regione' => 'Toscana'],
|
||||
['nome' => 'Gubbio', 'regione' => 'Umbria'],
|
||||
['nome' => 'Imola', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Isernia', 'regione' => 'Molise'],
|
||||
['nome' => 'L\'Aquila', 'regione' => 'Abruzzo'],
|
||||
['nome' => 'La Spezia', 'regione' => 'Liguria'],
|
||||
['nome' => 'Lamezia Terme', 'regione' => 'Calabria'],
|
||||
['nome' => 'Latina', 'regione' => 'Lazio'],
|
||||
['nome' => 'Lecce', 'regione' => 'Puglia'],
|
||||
['nome' => 'Lecco', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Livorno', 'regione' => 'Toscana'],
|
||||
['nome' => 'Lodi', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Lucca', 'regione' => 'Toscana'],
|
||||
['nome' => 'Lunedì', 'regione' => 'Marche'],
|
||||
['nome' => 'Macerata', 'regione' => 'Marche'],
|
||||
['nome' => 'Mantova', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Massa', 'regione' => 'Toscana'],
|
||||
['nome' => 'Matera', 'regione' => 'Basilicata'],
|
||||
['nome' => 'Messina', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Milano', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Modena', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Monaco', 'regione' => 'Germania'],
|
||||
['nome' => 'Mongolia', 'regione' => 'Asia'],
|
||||
['nome' => 'Monreale', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Montefeltro', 'regione' => 'Marche'],
|
||||
['nome' => 'Montepulciano', 'regione' => 'Toscana'],
|
||||
['nome' => 'Monza', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Napoli', 'regione' => 'Campania'],
|
||||
['nome' => 'Novara', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Nuoro', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Oristano', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Otranto', 'regione' => 'Puglia'],
|
||||
['nome' => 'Padova', 'regione' => 'Veneto'],
|
||||
['nome' => 'Palermo', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Parma', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Pavia', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Perugia', 'regione' => 'Umbria'],
|
||||
['nome' => 'Pesaro', 'regione' => 'Marche'],
|
||||
['nome' => 'Piacenza', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Pisa', 'regione' => 'Toscana'],
|
||||
['nome' => 'Pistoia', 'regione' => 'Toscana'],
|
||||
['nome' => 'Pordenone', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Potenza', 'regione' => 'Basilicata'],
|
||||
['nome' => 'Prato', 'regione' => 'Toscana'],
|
||||
['nome' => 'Ragusa', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Ravenna', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Reggio Calabria', 'regione' => 'Calabria'],
|
||||
['nome' => 'Reggio Emilia', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Rieti', 'regione' => 'Lazio'],
|
||||
['nome' => 'Rimini', 'regione' => 'Emilia-Romagna'],
|
||||
['nome' => 'Roma', 'regione' => 'Lazio'],
|
||||
['nome' => 'Rosario', 'regione' => 'Argentina'],
|
||||
['nome' => 'Rovigo', 'regione' => 'Veneto'],
|
||||
['nome' => 'Salerno', 'regione' => 'Campania'],
|
||||
['nome' => 'San Severo', 'regione' => 'Puglia'],
|
||||
['nome' => 'Sassari', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Savona', 'regione' => 'Liguria'],
|
||||
['nome' => 'Siena', 'regione' => 'Toscana'],
|
||||
['nome' => 'Siracusa', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Sondrio', 'regione' => 'Lombardia'],
|
||||
['nome' => 'Spezia', 'regione' => 'Liguria'],
|
||||
['nome' => 'Spoleto', 'regione' => 'Umbria'],
|
||||
['nome' => 'Syracuse', 'regione' => 'USA'],
|
||||
['nome' => 'Taranto', 'regione' => 'Puglia'],
|
||||
['nome' => 'Tempio Ampurias', 'regione' => 'Sardegna'],
|
||||
['nome' => 'Teramo', 'regione' => 'Abruzzo'],
|
||||
['nome' => 'Terni', 'regione' => 'Umbria'],
|
||||
['nome' => 'Tirana', 'regione' => 'Albania'],
|
||||
['nome' => 'Torino', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Tortona', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Trani', 'regione' => 'Puglia'],
|
||||
['nome' => 'Trapani', 'regione' => 'Sicilia'],
|
||||
['nome' => 'Trento', 'regione' => 'Trentino-Alto Adige'],
|
||||
['nome' => 'Treviso', 'regione' => 'Veneto'],
|
||||
['nome' => 'Trieste', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Udine', 'regione' => 'Friuli-Venezia Giulia'],
|
||||
['nome' => 'Urbino', 'regione' => 'Marche'],
|
||||
['nome' => 'Vaticano', 'regione' => 'Lazio'],
|
||||
['nome' => 'Vercelli', 'regione' => 'Piemonte'],
|
||||
['nome' => 'Verona', 'regione' => 'Veneto'],
|
||||
['nome' => 'Vibo Valentia', 'regione' => 'Calabria'],
|
||||
['nome' => 'Vicenza', 'regione' => 'Veneto'],
|
||||
['nome' => 'Viterbo', 'regione' => 'Lazio'],
|
||||
['nome' => 'Vittorio Veneto', 'regione' => 'Veneto'],
|
||||
];
|
||||
|
||||
foreach ($diocesi as $d) {
|
||||
Diocesi::create($d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\RolePreset;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RolePresetSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
RolePreset::firstOrCreate(
|
||||
['name' => 'admin'],
|
||||
[
|
||||
'description' => 'Amministratore con accesso completo a tutti i moduli',
|
||||
'permissions' => RolePreset::adminPreset(),
|
||||
]
|
||||
);
|
||||
|
||||
RolePreset::firstOrCreate(
|
||||
['name' => 'operatore'],
|
||||
[
|
||||
'description' => 'Operatore con accesso completo a individui/gruppi/eventi, sola lettura per documenti/mailing',
|
||||
'permissions' => RolePreset::operatorePreset(),
|
||||
]
|
||||
);
|
||||
|
||||
RolePreset::firstOrCreate(
|
||||
['name' => 'lettura'],
|
||||
[
|
||||
'description' => 'Sola lettura su tutti i moduli',
|
||||
'permissions' => RolePreset::letturaPreset(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$permissions = [
|
||||
'view individuals',
|
||||
'create individuals',
|
||||
'edit individuals',
|
||||
'delete individuals',
|
||||
'view groups',
|
||||
'create groups',
|
||||
'edit groups',
|
||||
'delete groups',
|
||||
'view events',
|
||||
'create events',
|
||||
'edit events',
|
||||
'delete events',
|
||||
'view documents',
|
||||
'create documents',
|
||||
'edit documents',
|
||||
'delete documents',
|
||||
'view mailing lists',
|
||||
'create mailing lists',
|
||||
'edit mailing lists',
|
||||
'delete mailing lists',
|
||||
'send mailing',
|
||||
'manage settings',
|
||||
'manage tipologie',
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::firstOrCreate(['name' => $permission]);
|
||||
}
|
||||
|
||||
$admin = Role::firstOrCreate(['name' => 'admin']);
|
||||
$admin->syncPermissions($permissions);
|
||||
|
||||
$user = Role::firstOrCreate(['name' => 'user']);
|
||||
$user->syncPermissions([
|
||||
'view individuals',
|
||||
'create individuals',
|
||||
'edit individuals',
|
||||
'view groups',
|
||||
'view events',
|
||||
'create events',
|
||||
'edit events',
|
||||
'view documents',
|
||||
'create documents',
|
||||
'edit documents',
|
||||
'view mailing lists',
|
||||
'send mailing',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user