new helpdesk module
This commit is contained in:
+3
-2
@@ -13,12 +13,13 @@ return new class extends Migration {
|
||||
Schema::create('helpdesk_comments', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('ticket_id')->constrained('helpdesk_tickets')->cascadeOnDelete();
|
||||
$table->foreignId('parent_id')->nullable()->constrained('helpdesk_comments')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->longText('body');
|
||||
$table->boolean('is_internal')->default(false);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['ticket_id', 'created_at']);
|
||||
$table->index(['ticket_id', 'parent_id', 'created_at']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_attachments', static function (Blueprint $table): void {
|
||||
@@ -33,7 +34,7 @@ return new class extends Migration {
|
||||
$table->unsignedBigInteger('size')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['ticket_id', 'created_at']);
|
||||
$table->index(['ticket_id', 'comment_id', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/** @return void */
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('helpdesk_git_repositories', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->foreignId('project_id')->nullable()->constrained('helpdesk_projects')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('provider', 40)->default('git');
|
||||
$table->string('remote_url', 500);
|
||||
$table->string('default_branch', 120)->default('main');
|
||||
$table->string('webhook_secret', 120)->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['company_id', 'project_id']);
|
||||
$table->index(['provider', 'is_active']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_git_commits', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('repository_id')->constrained('helpdesk_git_repositories')->cascadeOnDelete();
|
||||
$table->foreignId('ticket_id')->nullable()->constrained('helpdesk_tickets')->nullOnDelete();
|
||||
$table->string('hash', 80);
|
||||
$table->string('short_hash', 16);
|
||||
$table->string('branch', 120)->nullable();
|
||||
$table->string('author_name', 160)->nullable();
|
||||
$table->string('author_email', 190)->nullable();
|
||||
$table->text('message');
|
||||
$table->string('url', 500)->nullable();
|
||||
$table->timestamp('committed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['repository_id', 'hash']);
|
||||
$table->index(['ticket_id', 'committed_at']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_workflow_templates', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('name', 160);
|
||||
$table->string('event', 80);
|
||||
$table->string('subject', 220);
|
||||
$table->longText('html_body');
|
||||
$table->longText('text_body')->nullable();
|
||||
$table->string('to_role', 40)->default('requester');
|
||||
$table->string('cc', 500)->nullable();
|
||||
$table->string('bcc', 500)->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event', 'is_active']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_workflow_logs', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('template_id')->nullable()->constrained('helpdesk_workflow_templates')->nullOnDelete();
|
||||
$table->foreignId('ticket_id')->nullable()->constrained('helpdesk_tickets')->nullOnDelete();
|
||||
$table->string('event', 80);
|
||||
$table->string('recipient', 190)->nullable();
|
||||
$table->string('subject', 220)->nullable();
|
||||
$table->string('status', 40)->default('pending');
|
||||
$table->text('error')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['ticket_id', 'event']);
|
||||
$table->index(['status', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('helpdesk_workflow_logs');
|
||||
Schema::dropIfExists('helpdesk_workflow_templates');
|
||||
Schema::dropIfExists('helpdesk_git_commits');
|
||||
Schema::dropIfExists('helpdesk_git_repositories');
|
||||
}
|
||||
};
|
||||
@@ -11,6 +11,7 @@ use Modules\Helpdesk\Models\Priority;
|
||||
use Modules\Helpdesk\Models\Project;
|
||||
use Modules\Helpdesk\Models\Status;
|
||||
use Modules\Helpdesk\Models\Team;
|
||||
use Modules\Helpdesk\Models\WorkflowTemplate;
|
||||
|
||||
final class HelpdeskDatabaseSeeder extends Seeder
|
||||
{
|
||||
@@ -51,5 +52,18 @@ final class HelpdeskDatabaseSeeder extends Seeder
|
||||
'color' => 'blue',
|
||||
'description' => 'Default project for internal helpdesk tickets.',
|
||||
]);
|
||||
|
||||
foreach ([
|
||||
['name' => 'Ticket raised requester notice', 'event' => 'ticket.created', 'subject' => 'Ticket {{ ticket.reference }} has been raised', 'html_body' => '<p>Hello {{ requester.name }},</p><p>Your ticket <strong>{{ ticket.reference }}</strong> has been raised successfully.</p><p><strong>Subject:</strong> {{ ticket.subject }}</p><p><strong>Priority:</strong> {{ ticket.priority }}</p>', 'to_role' => 'requester'],
|
||||
['name' => 'Ticket updated requester notice', 'event' => 'ticket.updated', 'subject' => 'Ticket {{ ticket.reference }} has been updated', 'html_body' => '<p>Hello {{ requester.name }},</p><p>Your ticket <strong>{{ ticket.reference }}</strong> has been updated.</p><p><strong>Status:</strong> {{ ticket.status }}</p><p><strong>Priority:</strong> {{ ticket.priority }}</p>', 'to_role' => 'requester'],
|
||||
['name' => 'Ticket response requester notice', 'event' => 'ticket.commented', 'subject' => 'New response on ticket {{ ticket.reference }}', 'html_body' => '<p>Hello {{ requester.name }},</p><p>A new response has been added to <strong>{{ ticket.reference }}</strong>.</p><p><strong>Subject:</strong> {{ ticket.subject }}</p>', 'to_role' => 'requester'],
|
||||
['name' => 'Ticket closed requester notice', 'event' => 'ticket.closed', 'subject' => 'Ticket {{ ticket.reference }} has been closed', 'html_body' => '<p>Hello {{ requester.name }},</p><p>Your ticket <strong>{{ ticket.reference }}</strong> has been closed.</p><p>Thank you for using the support desk.</p>', 'to_role' => 'requester'],
|
||||
] as $template) {
|
||||
WorkflowTemplate::query()->updateOrCreate(
|
||||
['name' => $template['name'], 'event' => $template['event']],
|
||||
$template + ['text_body' => null, 'cc' => null, 'bcc' => null, 'is_active' => true]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user