singleloginsystem/app/Livewire/Forms/CreateTicketForm.php
= cac5f4905b WIP: implement ticketing system with support for notifications and attachments
- Added database migrations for tickets, statuses, roles, users, and related associations.
- Introduced models and enums for ticket status, permissions, and notifications.
- Implemented `TicketService` for ticket management and notification handling.
- Created Livewire form and UI for raising tickets with file attachments and routing options.
- Added tests covering ticket creation, validation, notifications, and file uploads.
2026-05-25 13:04:43 +00:00

63 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Livewire\Forms;
use Livewire\Form;
class CreateTicketForm extends Form
{
public ?int $connectedAppId = null;
public string $issueCategory = 'Billing Query';
public string $description = '';
public string $routingType = 'none';
public array $notifiedRoleIds = [];
public array $notifiedUserIds = [];
public mixed $attachment = null;
/**
* Define the validation rules dynamically.
*
* @return array<string, string>
*/
public function rules(): array
{
return [
'connectedAppId' => 'nullable|exists:connected_apps,id',
'issueCategory' => 'required|string',
'routingType' => 'nullable|in:role,user,none',
'notifiedRoleIds' => 'role' === $this->routingType ? 'required|array|min:1' : 'nullable|array',
'notifiedRoleIds.*' => 'role' === $this->routingType ? 'exists:roles,id' : 'nullable',
'notifiedUserIds' => 'user' === $this->routingType ? 'required|array|min:1' : 'nullable|array',
'notifiedUserIds.*' => 'user' === $this->routingType ? 'exists:users,id' : 'nullable',
'description' => 'Others' === $this->issueCategory ? 'required|string|min:20' : 'nullable|string',
'attachment' => 'Others' === $this->issueCategory ? 'nullable|file|mimes:jpg,jpeg,png,pdf|max:5120' : 'nullable',
];
}
/**
* Define validation attributes.
*
* @return array<string, string>
*/
public function validationAttributes(): array
{
return [
'connectedAppId' => 'service',
'issueCategory' => 'issue category',
'routingType' => 'routing type',
'notifiedRoleIds' => 'notified roles',
'notifiedUserIds' => 'notified users',
'description' => 'description',
'attachment' => 'file attachment',
];
}
}