ledgerrz/database/seeders/DatabaseSeeder.php
Daan Meijer 10bd46a53e
Some checks failed
linter / quality (push) Failing after 1m2s
tests / ci (8.3) (push) Failing after 48s
tests / ci (8.4) (push) Failing after 1m5s
tests / ci (8.5) (push) Failing after 1m5s
formatting, juiste use voor UpdateDynamicRequest
2026-06-22 00:10:39 +02:00

335 lines
12 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Dynamic;
use App\Models\Ledger;
use App\Models\Message;
use App\Models\Mutation;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
DB::transaction(function () {
// 1. Create Core Users
$testUser = User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
'password' => Hash::make('password'),
]);
$alice = User::factory()->create([
'name' => 'Domina Alice',
'email' => 'alice@example.com',
'password' => Hash::make('password'),
]);
$bob = User::factory()->create([
'name' => 'Submissive Bob',
'email' => 'bob@example.com',
'password' => Hash::make('password'),
]);
$charles = User::factory()->create([
'name' => 'Master Charles',
'email' => 'charles@example.com',
'password' => Hash::make('password'),
]);
// Create some random general users
User::factory(5)->create();
// ----------------------------------------------------
// 2. Seed Dynamic 1: The Velvet Sanctuary
// ----------------------------------------------------
$velvetSanctuary = Dynamic::create([
'name' => 'The Velvet Sanctuary',
'rules' => "1. Respect limits and boundaries at all times.\n2. Submit daily logs for curfew and chores.\n3. Maintain proper protocol in the general discussion.",
]);
// Add participants (Test User is owner, Alice is owner, Bob is submissive/participant)
$velvetSanctuary->participants()->attach($testUser->id, ['role' => 'owner', 'display_name' => 'The Master']);
$velvetSanctuary->participants()->attach($alice->id, ['role' => 'owner']);
$velvetSanctuary->participants()->attach($bob->id, ['role' => 'participant', 'display_name' => 'Bitch Boi']);
// Chat has been auto-created by the booted hook on Dynamic
$velvetChat = $velvetSanctuary->chat;
// Seed Dynamic Chat Messages
Message::create([
'chat_id' => $velvetChat->id,
'user_id' => $alice->id,
'content' => 'Good morning everyone. Bob, please ensure the Obsidian room is polished before 4 PM.',
]);
Message::create([
'chat_id' => $velvetChat->id,
'user_id' => $testUser->id,
'content' => 'I will review the curfew log later today.',
]);
Message::create([
'chat_id' => $velvetChat->id,
'user_id' => $bob->id,
'content' => "Yes, Sir. Yes, Ma'am. I am starting on the chores now.",
]);
Message::create([
'chat_id' => $velvetChat->id,
'user_id' => $testUser->id,
'content' => 'Excellent. Keep up the high standard.',
]);
// Add Ledgers
$curfewLedger = Ledger::create([
'dynamic_id' => $velvetSanctuary->id,
'name' => 'Curfew Compliance',
'rules' => 'Must be in bed and checked in by 11:00 PM.',
'score' => 35,
'alignment' => 'positive',
]);
$cleaningLedger = Ledger::create([
'dynamic_id' => $velvetSanctuary->id,
'name' => 'Dungeon Cleaning',
'rules' => 'Earn +10 to +20 points for cleaning/setup. Penalty -10 for disorganization.',
'score' => 45,
'alignment' => 'neutral',
]);
$etiquetteLedger = Ledger::create([
'dynamic_id' => $velvetSanctuary->id,
'name' => 'Protocol & Etiquette',
'rules' => 'Address others by correct titles. +5 per infraction.',
'score' => 15,
'alignment' => 'negative',
]);
// Seed Curfew Mutations
Mutation::create([
'ledger_id' => $curfewLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 10,
'description' => 'Checked in by 10:45 PM on Friday',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $curfewLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 15,
'description' => 'Checked in by 10:30 PM on Saturday',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $curfewLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 10,
'description' => 'Checked in by 10:50 PM on Sunday',
'status' => 'approved',
]);
// Seed Cleaning Mutations
Mutation::create([
'ledger_id' => $cleaningLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 15,
'description' => 'Deep cleaning of the main chamber',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $cleaningLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 20,
'description' => 'Arranged gear rack and polished leather accessories',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $cleaningLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => 10,
'description' => 'Mopped obsidian floors',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $cleaningLedger->id,
'user_id' => $alice->id,
'type' => 'penalty',
'amount' => -10,
'description' => 'Left keys in the locks unmonitored',
'status' => 'approved',
]);
// Seed Pending Mutation with its own Chat Messages!
$pendingMutation = Mutation::create([
'ledger_id' => $cleaningLedger->id,
'user_id' => $bob->id,
'type' => 'addition',
'amount' => 10,
'description' => 'Weekly chore submission - dusting shelves',
'status' => 'pending',
]);
// Pending mutation chat messages (chat is auto-created on booted)
$pendingMutationChat = $pendingMutation->chat;
Message::create([
'chat_id' => $pendingMutationChat->id,
'user_id' => $bob->id,
'content' => 'I have finished the shelves. Please approve when convenient.',
]);
Message::create([
'chat_id' => $pendingMutationChat->id,
'user_id' => $alice->id,
'content' => "I checked them; there is still some dust on the top shelf. I'll leave this pending until it's perfect.",
]);
Message::create([
'chat_id' => $pendingMutationChat->id,
'user_id' => $bob->id,
'content' => 'Apologies, Ma\'am. I will re-wipe the top section immediately!',
]);
// Seed Etiquette Mutations
Mutation::create([
'ledger_id' => $etiquetteLedger->id,
'user_id' => $bob->id,
'type' => 'penalty',
'amount' => 5,
'description' => 'Interrupted Domina Alice during daily instructions',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $etiquetteLedger->id,
'user_id' => $bob->id,
'type' => 'penalty',
'amount' => 10,
'description' => 'Forgot correct posture during morning roll call',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $etiquetteLedger->id,
'user_id' => $bob->id,
'type' => 'penalty',
'amount' => 5,
'description' => 'Spoke out of turn in general chat',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $etiquetteLedger->id,
'user_id' => $bob->id,
'type' => 'reward',
'amount' => -5,
'description' => 'Excellent reciting of the house codes',
'status' => 'approved',
]);
// ----------------------------------------------------
// 3. Seed Dynamic 2: Obsidian Household Agreement
// ----------------------------------------------------
$obsidianHousehold = Dynamic::create([
'name' => 'Obsidian Household Agreement',
'rules' => "1. All residents must do their fair share of maintenance.\n2. Coffee machine must be refilled immediately when empty.",
]);
$obsidianHousehold->participants()->attach($alice->id, ['role' => 'owner']);
$obsidianHousehold->participants()->attach($testUser->id, ['role' => 'participant']);
$obsidianHousehold->participants()->attach($charles->id, ['role' => 'participant']);
$obsidianChat = $obsidianHousehold->chat;
Message::create([
'chat_id' => $obsidianChat->id,
'user_id' => $alice->id,
'content' => "Who finished the coffee beans and didn't put them on the shopping list?",
]);
Message::create([
'chat_id' => $obsidianChat->id,
'user_id' => $charles->id,
'content' => "Wasn't me, I only drink tea.",
]);
Message::create([
'chat_id' => $obsidianChat->id,
'user_id' => $testUser->id,
'content' => 'My apologies! I did refill the hopper, but forgot to list the replacement bag. I will buy a new pack tonight.',
]);
Message::create([
'chat_id' => $obsidianChat->id,
'user_id' => $alice->id,
'content' => 'Thank you, Test User. Appreciate the honesty.',
]);
// Add Ledgers
$kitchenLedger = Ledger::create([
'dynamic_id' => $obsidianHousehold->id,
'name' => 'Kitchen Chores',
'rules' => 'Scores for dishwashing, trash duty, and deep oven cleaning.',
'score' => 40,
'alignment' => 'positive',
]);
$coffeeLedger = Ledger::create([
'dynamic_id' => $obsidianHousehold->id,
'name' => 'Coffee Machine Maintenance',
'rules' => ' refill beans and descale monthly.',
'score' => 10,
'alignment' => 'neutral',
]);
// Seed Chores Mutations
Mutation::create([
'ledger_id' => $kitchenLedger->id,
'user_id' => $testUser->id,
'type' => 'reward',
'amount' => 25,
'description' => 'Emptied and loaded the dishwasher',
'status' => 'approved',
]);
Mutation::create([
'ledger_id' => $kitchenLedger->id,
'user_id' => $testUser->id,
'type' => 'reward',
'amount' => 15,
'description' => 'Took out recycling and trash bags',
'status' => 'approved',
]);
// Seed Coffee Mutations
Mutation::create([
'ledger_id' => $coffeeLedger->id,
'user_id' => $testUser->id,
'type' => 'reward',
'amount' => 10,
'description' => 'Descaled and refilled coffee beans',
'status' => 'approved',
]);
});
}
}