Premier commit

This commit is contained in:
jeremy bayse
2026-02-09 11:27:21 +01:00
commit 89a369964d
114 changed files with 17837 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,51 @@
<?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->string('role')->default('reader'); // admin, manager, reader
$table->boolean('is_active')->default(false);
$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')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* 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,37 @@
<?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('contracts', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('reference')->unique()->nullable();
$table->string('provider');
$table->string('status')->default('draft'); // active, expired, pending, cancelled
$table->date('start_date');
$table->date('end_date')->nullable();
$table->decimal('amount', 10, 2)->nullable();
$table->string('currency', 3)->default('EUR');
$table->text('notes')->nullable();
$table->string('type')->default('other'); // microsoft_365, domain, software, fiber, other
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('contracts');
}
};

View File

@@ -0,0 +1,31 @@
<?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('contract_meta', function (Blueprint $table) {
$table->id();
$table->foreignId('contract_id')->constrained()->cascadeOnDelete();
$table->string('key');
$table->text('value')->nullable();
$table->unique(['contract_id', 'key']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('contract_meta');
}
};

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('audit_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('action');
$table->text('description')->nullable();
$table->ipAddress('ip_address')->nullable();
$table->string('user_agent')->nullable();
$table->json('changes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('audit_logs');
}
};

View File

@@ -0,0 +1,34 @@
<?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('documents', function (Blueprint $table) {
$table->id();
$table->foreignId('contract_id')->constrained()->cascadeOnDelete();
$table->string('filename');
$table->string('path');
$table->string('mime_type')->nullable();
$table->integer('size')->nullable();
$table->text('description')->nullable();
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documents');
}
};

View File

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

View File

@@ -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('contracts', function (Blueprint $table) {
$table->foreignId('municipality_id')->nullable()->constrained()->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('contracts', function (Blueprint $table) {
$table->dropConstrainedForeignId('municipality_id');
});
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('license_levels', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('type')->default('microsoft_365');
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('license_levels');
}
};

View File

@@ -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('municipalities', function (Blueprint $table) {
$table->boolean('is_active')->default(true);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('municipalities', function (Blueprint $table) {
$table->dropColumn('is_active');
});
}
};

View File

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

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('links', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('url');
$table->string('icon')->nullable()->default('bi-link');
$table->string('color')->nullable()->default('primary'); // For styling badge/icon
$table->integer('order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('links');
}
};

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call(MunicipalitySeeder::class);
// User::factory(10)->create();
User::factory()->create([
'name' => 'Admin User',
'email' => 'admin@dsigest.local',
'password' => \Illuminate\Support\Facades\Hash::make('password'),
'role' => 'admin',
'is_active' => true,
]);
User::factory()->create([
'name' => 'Manager User',
'email' => 'manager@dsigest.local',
'password' => \Illuminate\Support\Facades\Hash::make('password'),
'role' => 'manager',
'is_active' => true,
]);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Database\Seeders;
use App\Models\LicenseLevel;
use Illuminate\Database\Seeder;
class LicenseLevelSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$levels = [
'Basic',
'Standard',
'Premium',
'E3',
'E5',
'F3',
];
foreach ($levels as $level) {
LicenseLevel::firstOrCreate(['name' => $level], ['type' => 'microsoft_365']);
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Seeders;
use App\Models\Link;
use Illuminate\Database\Seeder;
class LinkSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Link::create([
'title' => 'Google',
'url' => 'https://google.com',
'icon' => 'bi-google',
'color' => 'danger',
'order' => 10,
]);
Link::create([
'title' => 'Office 365',
'url' => 'https://portal.office.com',
'icon' => 'bi-microsoft',
'color' => 'primary',
'order' => 20,
]);
Link::create([
'title' => 'Support',
'url' => '#',
'icon' => 'bi-life-preserver',
'color' => 'info',
'order' => 30,
]);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Seeders;
use App\Models\Municipality;
use Illuminate\Database\Seeder;
class MunicipalitySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$municipalities = [
['name' => 'Béziers', 'zip_code' => '34500'],
['name' => 'Alignan-du-Vent', 'zip_code' => '34290'],
['name' => 'Bassan', 'zip_code' => '34290'],
['name' => 'Boujan-sur-Libron', 'zip_code' => '34760'],
['name' => 'Cers', 'zip_code' => '34420'],
['name' => 'Corneilhan', 'zip_code' => '34490'],
['name' => 'Coulobres', 'zip_code' => '34290'],
['name' => 'Espondeilhan', 'zip_code' => '34290'],
['name' => 'Lieuran-lès-Béziers', 'zip_code' => '34290'],
['name' => 'Lignan-sur-Orb', 'zip_code' => '34490'],
['name' => 'Montblanc', 'zip_code' => '34290'],
['name' => 'Sauvian', 'zip_code' => '34410'],
['name' => 'Sérignan', 'zip_code' => '34410'],
['name' => 'Servian', 'zip_code' => '34290'],
['name' => 'Valras-Plage', 'zip_code' => '34350'],
['name' => 'Valros', 'zip_code' => '34290'],
['name' => 'Villeneuve-lès-Béziers', 'zip_code' => '34420'],
];
foreach ($municipalities as $municipality) {
Municipality::firstOrCreate(['name' => $municipality['name']], $municipality);
}
}
}