Implemented the authenticated admin contact system.

This commit is contained in:
2026-05-16 22:02:32 +03:30
parent 04e7931ccc
commit e633805ed3
28 changed files with 2200 additions and 14 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Models\SupportAttachment;
use App\Models\SupportMessage;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SupportAttachment>
*/
class SupportAttachmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'support_message_id' => SupportMessage::factory(),
'disk' => 'local',
'path' => 'support/testing/debug.log',
'original_name' => 'debug.log',
'mime_type' => 'text/plain',
'size' => 128,
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Models\SupportConversation;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SupportConversation>
*/
class SupportConversationFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'category' => fake()->randomElement(SupportConversation::categories()),
'subject' => fake()->sentence(4),
'status' => SupportConversation::STATUS_OPEN,
'last_message_at' => now(),
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\SupportConversation;
use App\Models\SupportMessage;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SupportMessage>
*/
class SupportMessageFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'support_conversation_id' => SupportConversation::factory(),
'user_id' => User::factory(),
'body' => fake()->paragraph(),
];
}
}

View 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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('support_conversations', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('category')->index();
$table->string('subject', 120);
$table->string('status')->default('open')->index();
$table->timestamp('last_message_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('support_conversations');
}
};

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('support_messages', function (Blueprint $table) {
$table->id();
$table->foreignId('support_conversation_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->text('body');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('support_messages');
}
};

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('support_attachments', function (Blueprint $table) {
$table->id();
$table->foreignId('support_message_id')->constrained()->cascadeOnDelete();
$table->string('disk')->default('local');
$table->string('path');
$table->string('original_name');
$table->string('mime_type');
$table->unsignedBigInteger('size');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('support_attachments');
}
};