unknown 1 månad sedan
förälder
incheckning
361c378778

+ 14 - 1
app/Http/Controllers/AdminController.php

@@ -4,5 +4,18 @@ namespace App\Http\Controllers;
 
 class AdminController extends Controller
 {
-    //
+    public function dashboard(Request $request, Applicaiton $application)
+    {
+        $query = $application::with('user', 'course');
+        if ($request->filled('status')) { $query->where('status')->whereIn('status', ['new', 'in_progress'])->first(); }
+        $appliation = $query->latest()->paginate(10);
+        return view(route('admin.dashboard'), compact('application'));
+    }
+
+    public function updateStatus(Request $request, Applicaiton $application)
+    {
+        $request->validate('status' => ['required', 'string', Rule::in(['new', 'in_proggres', 'completed'])]);
+        $application->update('status', $request->status);
+        return back()->with('success', 'успешно обновлен статус');
+    }
 }

+ 21 - 1
app/Http/Controllers/ApplicationController.php

@@ -6,6 +6,26 @@ class ApplicationController extends Controller
 {
     public function index()
     {
-        Auth::user()->application()->with("course")->latest()->pagination(10);
+        $application = Auth::user()->application()->with("course")->latest()->pagination(10);
+        return view(route('application.index'), compact('application'));
+    }
+
+    public function create()
+    {
+        $courses = Course::all();
+        return view(route('application.create'), compact('courses'));
+    }
+
+    public function store()
+    {
+        $validated = $request->validate(['course_id' => ['required', 'exists:course,id'], 'start_date' => ['required', 'date', 'after:today'], 'payment_method' => ['required', 'string', Rule::in(['cash', 'phone_transfer'])]]);
+        $existingApplication = Auth::user()->application();
+    }
+
+    public function comment(Request $request, Application $application)
+    {
+        if (!$application->canAddCommnet()) { return back()->withErrors('error', 'не получчилось оставить коммнетарий'); }
+        $application->update(['comment' => $request->comment]);
+        return back()->with('success', 'Успешно');
     }
 }

+ 3 - 4
database/migrations/0001_01_01_000000_create_users_table.php

@@ -6,15 +6,14 @@ 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('login')->unique();
             $table->string('email')->unique();
+            $table->text('full_name');
+            $table->string('phone');
             $table->timestamp('email_verified_at')->nullable();
             $table->string('password');
             $table->rememberToken();

+ 30 - 0
database/migrations/0001_01_01_000003_create_courses_table.php

@@ -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
+{
+    public function up(): void
+    {
+        Schema::create('course', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->string('description');
+            $table->decimal('price', 2, 8);
+            $table->rememberToken();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('users');
+        Schema::dropIfExists('password_reset_tokens');
+        Schema::dropIfExists('sessions');
+    }
+};

+ 33 - 0
database/migrations/0001_01_01_000004_create_applications_table.php

@@ -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
+{
+    public function up(): void
+    {
+        Schema::create('users', function (Blueprint $table) {
+            $table->id();
+            $table->integral('user_id');
+            $table->integral('course_id');
+            $table->date('start_date');
+            $table->enum('payment_method', ['cash', 'phone_transfer']);
+            $table->enum('status', ['new', 'in_progress', 'competed']);
+            $table->text('comment')->nullable();
+            $table->rememberToken();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('users');
+        Schema::dropIfExists('password_reset_tokens');
+        Schema::dropIfExists('sessions');
+    }
+};

+ 35 - 4
database/seeders/DatabaseSeeder.php

@@ -13,11 +13,42 @@ class DatabaseSeeder extends Seeder
      */
     public function run(): void
     {
-        // User::factory(10)->create();
+        User::create([
+            'login' => 'Admin',
+            'email' => 'admin@example.com',
+            'full_name' => 'Администратор',
+            'phone' => '8(999)111-11-11',
+            'password' => Hash::make('KorokNET'),
+        ]);
 
-        User::factory()->create([
-            'name' => 'Test User',
-            'email' => 'test@example.com',
+        User::create([
+            'login' => 'Admin',
+            'email' => 'admin@example.com',
+            'full_name' => 'Администратор',
+            'phone' => '8(999)111-11-11',
+            'password' => Hash::make('KorokNET'),
         ]);
+
+        $courses = [
+            [
+                "name" => 'Алгоритмизация',
+                "description" => 'Алгоритмизация',
+                "price" =>  15000,
+            ],
+            [
+                "name" => 'Базы данных',
+                "description" => 'Базы данных',
+                "price" =>  15000,
+            ],
+            [
+                "name" => 'дизайн',
+                "description" => 'дизайн',
+                "price" =>  15000,
+            ],
+        ];
+
+        foreach ($courses as $course) {
+            Course::create($course);
+        }
     }
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 0
public/bootstrap.min.css


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5 - 0
public/bootstrap.min.js


Vissa filer visades inte eftersom för många filer har ändrats