Basic tenant structure
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
32
database/migrations/2026_01_30_140001_create_tenants.php
Normal file
32
database/migrations/2026_01_30_140001_create_tenants.php
Normal 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 {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('slug')->unique();
|
||||
$table->string('local_group_name');
|
||||
$table->string('email');
|
||||
$table->string('url');
|
||||
$table->string('account_iban');
|
||||
$table->string('city');
|
||||
$table->string('postcode');
|
||||
$table->string('gdpr_text')-> nullable();
|
||||
$table->string('impress_text')->nullable();
|
||||
$table->string('url_participation_rules')->nullable();
|
||||
$table->boolean('has_active_instance')->default(true);
|
||||
$table->boolean('is_active_local_group')->default(true);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
};
|
||||
106
database/migrations/2026_01_30_140002_create_users_table.php
Normal file
106
database/migrations/2026_01_30_140002_create_users_table.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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('user_roles', function (Blueprint $table) {
|
||||
$table->string('slug')->unique()->primary();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('eating_habits', function (Blueprint $table) {
|
||||
$table->string('slug')->unique()->primary();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('swimming_permissions', function (Blueprint $table) {
|
||||
$table->string('slug')->unique()->primary();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('first_aid_permissions', function (Blueprint $table) {
|
||||
$table->string('slug')->unique()->primary();
|
||||
$table->string('name');
|
||||
$table->string('description');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('tenant');
|
||||
$table->string('user_role');
|
||||
$table->string('username')->unique();
|
||||
$table->string('password')->nullable();
|
||||
$table->string('firstname');
|
||||
$table->string('nickname')->nullable();
|
||||
$table->string('lastname');
|
||||
$table->foreignId('local_group_id')->references('id')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->string('membership_id')->nullable();
|
||||
$table->string('address_1')->nullable();
|
||||
$table->string('address_2')->nullable();
|
||||
$table->string('postcode')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->date('birthday')->nullable();
|
||||
$table->string('medications')->nullable();
|
||||
$table->string('allergies')->nullable();
|
||||
$table->string('intolerances')->nullable();
|
||||
$table->string('eating_habits')->nullable();
|
||||
$table->string('swimming_permission')->nullable();
|
||||
$table->string('first_aid_permission')->nullable();
|
||||
$table->string('bank_account_iban')->nullable();
|
||||
$table->string('activation_token')->nullable();
|
||||
$table->boolean('activated')->default(false);
|
||||
|
||||
$table->foreign('tenant')->references('slug')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('user_role')->references('slug')->on('user_roles')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('swimming_permission')->references('slug')->on('swimming_permissions')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('eating_habits')->references('slug')->on('eating_habits')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('first_aid_permission')->references('slug')->on('first_aid_permissions')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
|
||||
$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');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('eating_habits');
|
||||
Schema::dropIfExists('swimming_permissions');
|
||||
Schema::dropIfExists('first_aid_permissions');
|
||||
}
|
||||
};
|
||||
43
database/migrations/2026_01_30_140010_create_cost_units.php
Normal file
43
database/migrations/2026_01_30_140010_create_cost_units.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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('cost_unit_types', function (Blueprint $table) {
|
||||
$table->string('slug')->primary();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Schema::create('cost_units', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('tenant');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->dateTime('billing_deadline');
|
||||
$table->float('distance_allowance');
|
||||
$table->boolean('mail_on_new')->default(true);
|
||||
$table->boolean('allow_new')->default(true);
|
||||
$table->boolean('archived')->default(false);
|
||||
$table->string('treasurers');
|
||||
|
||||
$table->foreign('tenant')->references('slug')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('type')->references('slug')->on('cost_unit_types')->cascadeOnDelete()->cascadeOnUpdate();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cost_units');
|
||||
Schema::dropIfExists('cost_unit_types');
|
||||
}
|
||||
};
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Installer\DevelopmentDataSeeder;
|
||||
use App\Installer\ProductionData;
|
||||
use App\Installer\ProductionDataSeeder;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@@ -15,11 +17,12 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
$productionSeeeder = new ProductionDataSeeder();
|
||||
$productionSeeeder->execute();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
if (str_ends_with(env('APP_URL'), 'mareike.local')) {
|
||||
$deveopmentDataSeeder = new DevelopmentDataSeeder();
|
||||
$deveopmentDataSeeder->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user