Commit iniziale

This commit is contained in:
2025-08-05 14:10:01 +02:00
commit 097b7e922d
505 changed files with 227792 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\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,
]);
}
}

View File

@@ -0,0 +1,49 @@
<?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::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
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();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
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');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,57 @@
<?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::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')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTagsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('tag_name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tags');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('cat_name',255);
$table->smallInteger('cat_entrata')->default(0);
$table->smallInteger('cat_uscita')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContosTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('contos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('nomeConto')->unique();
$table->string('Banca');
$table->string('IBAN')->nullable();
$table->decimal('saldo_iniziale',10,2)->default(0.00);
$table->longText('note')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('contos');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMovimentisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('movimentis', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->date('mov_data');
$table->unsignedBigInteger('mov_fk_categoria');
$table->foreign('mov_fk_categoria')->references('id')->on('categories');
$table->longText('mov_descrizione');
$table->decimal('mov_importo',8,2);
$table->unsignedBigInteger('mov_inserito_da');
$table->foreign('mov_inserito_da')->references('id')->on('users');
$table->unsignedBigInteger('mov_fk_tags');
$table->foreign('mov_fk_tags')->references('id')->on('tags');
$table->foreignId('conto_id')->constrained('contos');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('movimentis');
}
}

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAnagraficasTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('anagraficas', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('ang_cognome');
$table->string('ang_nome');
$table->string('ang_ragioneSociale',255)->nullable();
$table->string('ang_codiceFiscale',255)->nullable();
$table->string('ang_partitaIva',255)->nullable();
$table->longText('ang_indirizzo')->nullable();
$table->string('ang_CAP',10)->nullable();
$table->string('ang_Citta',255)->nullable();
$table->string('ang_Provincia',255)->nullable();
$table->string('ang_telefono',45);
$table->longText('ang_note')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('anagraficas');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContattosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contattos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->unsignedBigInteger('cnt_fk_anagraficaId');
$table->foreign('cnt_fk_anagraficaId')->references('id')->on('anagraficas')->onDelete('cascade');
$table->integer('cnt_tipo');
$table->longText('cnt_valore');
$table->longText('cnt_note');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contattos');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContatoreGasesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contatore_gases', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->date('gas_date');
$table->decimal('gas_lettura',10,3);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contatore_gases');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContatoreEnElsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contatore_en_els', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->date('enel_date');
$table->integer('enel_A');
$table->integer('enel_R');
$table->integer('enel_F1');
$table->integer('enel_F2');
$table->integer('enel_F3');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contatore_en_els');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEventsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('events', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->date('start');
$table->date('end');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('events');
}
}

View File

@@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCondominiosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('condominios', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->date('dal');
$table->date('al');
$table->foreignId('pertinenza_id');
$table->decimal('generali',10,2);
$table->decimal('generali_civico',10,2);
$table->decimal('risc_consumo',10,2);
$table->decimal('risc_millesimi',10,2);
$table->decimal('acqua_calda_consumo',10,2);
$table->decimal('acqua_fredda_consumo',10,2);
$table->decimal('ripart_spese',10,2);
$table->decimal('ascensore',10,2);
$table->decimal('scala',10,2);
$table->decimal('autorimessa',10,2);
$table->decimal('gest_inquilini',10,2);
$table->decimal('parcheggi_isola',10,2);
$table->decimal('percorsi_ped',10,2);
$table->decimal('cancello_viale',10,2);
$table->decimal('zone_comuni_gen',10,2);
$table->decimal('mov_personali',10,2);
$table->decimal('tot_gestione',10,2);
$table->decimal('saldi_fine_es_prec',10,2);
$table->decimal('rate_versate',10,2);
$table->decimal('saldo_finale',10,2);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('condominios');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDocumentisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('documentis', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('descrizione');
$table->string('path');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('documentis');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAutosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('autos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('targa',10);
$table->string('marca',10);
$table->string('modello',10);
$table->string('cilindrata',10);
$table->string('alimentazione',10);
$table->string('cvfiscali',10);
$table->string('ntelaio',30)->nullable();
$table->string('nmotore',30)->nullable();
$table->date('data_acquisto')->nullable();
$table->text('note')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('autos');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOperazionesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('operaziones', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->unsignedBigInteger('fk_auto_id');
$table->foreign('fk_auto_id')->references('id')->on('autos')->cascadeOnDelete();
$table->date('data');
$table->bigInteger('km');
$table->double('importo',10,2);
$table->string('type',100);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('operaziones');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRifornimentosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('rifornimentos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->double('eurolitro',10,2);
$table->double('litri',10,2);
$table->string('distributore',255);
$table->unsignedBigInteger('fk_operazione_id');
$table->foreign('fk_operazione_id')->references('id')->on('operaziones')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('rifornimentos');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateManutenzionesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('manutenziones', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->longText('descrizione');
$table->unsignedBigInteger('fk_operazione_id');
$table->foreign('fk_operazione_id')->references('id')->on('operaziones')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('manutenziones');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRevisionesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('revisiones', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->unsignedBigInteger('fk_operazione_id');
$table->foreign('fk_operazione_id')->references('id')->on('operaziones')->cascadeOnDelete();
$table->longText('descrizione');
$table->string('centrorevisione',255);
$table->boolean('superata');
$table->date('dataproxrevisione');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('revisiones');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAccessorisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accessoris', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->unsignedBigInteger('fk_operazione_id');
$table->foreign('fk_operazione_id')->references('id')->on('operaziones')->cascadeOnDelete();
$table->longText('descrizione');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('accessoris');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProgettisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('progettis', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('nome',255);
$table->longText('descrizione');
$table->date('data_creazione');
$table->date('data_inizio')->nullable();
$table->date('data_fine')->nullable();
$table->foreignId('fk_user')->constrained('users');
$table->decimal('budget',10,2)->nullable();
$table->enum('stato', ['aperto','bloccato','chiuso']);
$table->longtext('note')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('progettis');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRigaProgettosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('riga_progettos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->date('data');
$table->longText('descrizione');
$table->decimal('prezzo',10,2)->nullable();
$table->decimal('ore',10,2)->nullable();
$table->unsignedBigInteger('fk_id_progetto');
$table->foreign('fk_id_progetto')->references('id')->on('progettis');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('riga_progettos');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTasksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('titolo',255);
$table->longText('descrizione')->nullable();
$table->bigInteger('creato_da');
$table->bigInteger('assegnato_a');
$table->date('creato_il');
$table->date('termine_il');
$table->date('chiuso_il');
$table->enum('stato', ['Aperto', 'Chiuso'])->nullable()->default('Aperto');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Subtask extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('subtasks', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->foreignId('tasks_id')->onDelete('cascade');
$table->string('titolo',255);
$table->longText('descrizione')->nullable();
$table->bigInteger('creato_da');
$table->bigInteger('assegnato_a');
$table->date('creato_il');
$table->date('termine_il');
$table->date('chiuso_il');
$table->enum('stato', ['Aperto', 'Chiuso'])->nullable()->default('Aperto');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAvvisosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('avvisos', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->longtext('avviso');
$table->date('creato_il')->nullable()->default(date('Y-m-d'));
$table->bigInteger('creato_da');
$table->boolean('urgente')->nullable()->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('avvisos');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContrattisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contrattis', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('numero', 100)->nullable();
$table->string('nome', 100);
$table->date('datainizio');
$table->date('datatermine');
$table->string('fornitore', 100)->default('text');
$table->string('tipo', 100)->default('utenze');
$table->decimal('importo', 5, 2);
$table->date('scadenzapagamento');
$table->string('stato', 100)->default('attivo');
$table->longText('note')->nullable();
$table->string('filename',255)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contrattis');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGenDocsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('gen_docs', function (Blueprint $table) {
// Documenti generali definibili agganciabili a diverse entità
$table->id();
$table->timestamps();
$table->integer('entity')->unsigned();
$table->bigInteger('entity_id');
$table->string('filename', 255);
$table->longText('descrizione');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('gen_docs');
}
}

View File

@@ -0,0 +1,138 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
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';
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('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'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$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'], 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'])
->onDelete('cascade');
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'], 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'])
->onDelete('cascade');
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'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$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');
if (empty($tableNames)) {
throw new \Exception('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::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('todolists', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('todolists');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('central_tenants', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('central_tenants');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('import_rules', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('import_rules');
}
};

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class CategorieSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Inserisce le categorie necessarie
DB::table('categories')->insert(
[
'cat_name'=>'Automobili',
'cat_uscita'=>1,
'cat_entrata'=>0,
]
);
DB::table('categories')->insert(
[
'cat_name'=>'Stipendio',
'cat_uscita'=>0,
'cat_entrata'=>1]
);
DB::table('categories')->insert(
[
'cat_name'=>'Utenze',
'cat_uscita'=>1,
'cat_entrata'=>0]
);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ContoSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
DB::table('contos')->insert(
[
'nomeConto'=>'Contanti',
'Banca'=>'Contanti',
'IBAN'=>null,
]
);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// \App\Models\User::factory(10)->create();
$this->call([
// UserSeeder::class,
TagSeeder::class,
CategorieSeeder::class,
// RoleSeeder::class,
Documenti::class,
OnlySeeder::class,
ContoSeeder::class,
]);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Documenti as Doc;
class Documenti extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
Doc::create([
'id'=>0,
'descrizione' => 'Movimenti',
'path' => 'Movimenti',
],
[
'id' => 1,
'descrizione' => 'Contratti',
'path' => 'Contratti',
],
[
'id' => 2,
'descrizione' => 'Automobili',
'path' => 'Automobili',
],
[
'id' => 3,
'descrizione' => 'Progetti',
'path' => 'Progetti',
],
[
'id' => 4,
'descrizione' => 'Documenti',
'path' => 'Documenti',
]);
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\PermissionRegistrar;
use Illuminate\Support\Str;
class OnlySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Role Creation
$role_admin = Role::create([
'name' => 'admin'
]);
$role_user = Role::create([
'name' => 'user'
]);
$role_guest = Role::create([
'name' => 'guest'
]);
// Permission Creation
Permission::create([
'name' => 'conti'
]);
Permission::create([
'name' => 'consumi'
]);
Permission::create([
'name' => 'automobili'
]);
Permission::create([
'name' => 'contatti'
]);
Permission::create([
'name' => 'affitti'
]);
Permission::create([
'name' => 'progetti'
]);
Permission::create([
'name' => 'amministrazione'
]);
// Assegnazione permessi al ruolo user
$role_user->givePermissionTo('affitti');
$role_user->givePermissionTo('automobili');
$role_user->givePermissionTo('contatti');
$role_user->givePermissionTo('consumi');
$role_user->givePermissionTo('conti');
$role_user->givePermissionTo('progetti');
// Assegnazione permessi al ruolo guest
$role_guest->givePermissionTo('affitti');
// Il ruolo admin ha già tutti i permessi da middleware
$admin = User::create([
'name'=>'Amministratore',
'email'=>'admin@localhost.local',
'password'=>Hash::make('admin'),
])->assignRole('user')->assignRole('admin');
$user = User::create([
'name'=>'Utente',
'email'=>'user@localhost.local',
'password'=>Hash::make('user'),
])->assignRole('user');
$guest = User::create([
'name'=>'Guest',
'email'=>'guest@localhost.local',
'password'=>Hash::make('guest'),
])->assignRole('guest');
User::create(
[
'name'=>'SystemUser',
'email'=>'system@localhost.local',
'password'=>Hash::make(Str::random(16)),
]
);
}
}

View File

@@ -0,0 +1,117 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\PermissionRegistrar;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Role Creation
$role_admin = Role::create([
'name' => 'admin'
]);
$role_user = Role::create([
'name' => 'user'
]);
$role_guest = Role::create([
'name' => 'guest'
]);
// Permission Creation
Permission::create([
'name' => 'affitti'
]);
Permission::create([
'name' => 'appuntamenti'
]);
Permission::create([
'name' => 'avvisi'
]);
Permission::create([
'name' => 'contratti'
]);
Permission::create([
'name' => 'documenti'
]);
Permission::create([
'name' => 'meetingroom'
]);
Permission::create([
'name' => 'tasks'
]);
Permission::create([
'name' => 'conti'
]);
Permission::create([
'name' => 'consumi'
]);
Permission::create([
'name' => 'automobili'
]);
Permission::create([
'name' => 'contatti'
]);
Permission::create([
'name' => 'progetti'
]);
Permission::create([
'name' => 'amministrazione'
]);
// Assegnazione permessi al ruolo user
$role_user->givePermissionTo('affitti');
$role_user->givePermissionTo('automobili');
$role_user->givePermissionTo('contatti');
$role_user->givePermissionTo('consumi');
$role_user->givePermissionTo('conti');
$role_user->givePermissionTo('progetti');
// Assegnazione permessi al ruolo guest
$role_guest->givePermissionTo('affitti');
// Assegnazione permessi al ruolo admin
$role_admin->givePermissionTo('affitti');
$role_admin->givePermissionTo('automobili');
$role_admin->givePermissionTo('contatti');
$role_admin->givePermissionTo('consumi');
$role_admin->givePermissionTo('conti');
$role_admin->givePermissionTo('progetti');
$role_admin->givePermissionTo('amministrazione');
$role_admin->givePermissionTo('documenti');
$role_admin->givePermissionTo('appuntamenti');
$role_admin->givePermissionTo('avvisi');
$role_admin->givePermissionTo('tasks');
$role_admin->givePermissionTo('contratti');
$role_admin->givePermissionTo('meetingroom');
$admin = User::create([
'name'=>'Amministratore',
'email'=>'admin@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_admin);
$user = User::create([
'name'=>'Utente',
'email'=>'user@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_user);
$guest = User::create([
'name'=>'Guest',
'email'=>'guest@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_guest);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class TagSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
DB::table('tags')->insert(
['tag_name'=>'System']
);
DB::table('tags')->insert(
['tag_name'=>'da verificare']
);
}
}