From fa4823dd632cad6a5736c1d900a064647bb72c20 Mon Sep 17 00:00:00 2001
From: ryo <ryo@nopwd.lol>
Date: Tue, 11 Mar 2025 16:15:29 +0000
Subject: Added admin user that can change usres team

Fixed: player login based on user and password
Added: show errors to the user
---
 .../2025_03_06_091820_create_players_table.php     | 40 --------------------
 .../2025_03_08_132951_create_players_table.php     | 43 ++++++++++++++++++++++
 database/seeders/DatabaseSeeder.php                | 13 ++++---
 3 files changed, 51 insertions(+), 45 deletions(-)
 delete mode 100644 database/migrations/2025_03_06_091820_create_players_table.php
 create mode 100644 database/migrations/2025_03_08_132951_create_players_table.php

(limited to 'database')

diff --git a/database/migrations/2025_03_06_091820_create_players_table.php b/database/migrations/2025_03_06_091820_create_players_table.php
deleted file mode 100644
index d078edf..0000000
--- a/database/migrations/2025_03_06_091820_create_players_table.php
+++ /dev/null
@@ -1,40 +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('players', function (Blueprint $table) {
-            $table->id();
-            $table->timestamps();
-            $table->string('name');
-            $table->string('team');
-            $table->integer('score');
-        });
-
-        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('players');
-        Schema::dropIfExists('sessions');
-    }
-};
diff --git a/database/migrations/2025_03_08_132951_create_players_table.php b/database/migrations/2025_03_08_132951_create_players_table.php
new file mode 100644
index 0000000..13d4e24
--- /dev/null
+++ b/database/migrations/2025_03_08_132951_create_players_table.php
@@ -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('players', function (Blueprint $table) {
+            $table->id();
+            $table->timestamps();
+            $table->rememberToken();
+            $table->string('name')->unique();
+            $table->string('password');
+            $table->string('team');
+            $table->integer('score');
+            $table->boolean('is_admin')->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('players');
+        Schema::dropIfExists('sessions');
+    }
+};
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index d01a0ef..1342d58 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -2,9 +2,9 @@
 
 namespace Database\Seeders;
 
-use App\Models\User;
-// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+use App\Models\Player;
 use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\Hash;
 
 class DatabaseSeeder extends Seeder
 {
@@ -15,9 +15,12 @@ class DatabaseSeeder extends Seeder
     {
         // User::factory(10)->create();
 
-        User::factory()->create([
-            'name' => 'Test User',
-            'email' => 'test@example.com',
+        Player::create([
+            'name' => 'admin',
+            'password' => Hash::make('12345'),
+            'team' => 'none',
+            'score' => 100,
+            'is_admin' => true,
         ]);
     }
 }
-- 
cgit v1.2.3