ticker work proses

This commit is contained in:
Wian Drs
2026-06-22 13:34:49 +07:00
parent 844b8a0ff0
commit b52e67c428
22 changed files with 1193 additions and 16 deletions
@@ -0,0 +1,247 @@
<?php
namespace App\Http\Controllers\Ticket;
use App\Http\Controllers\ApiController;
use App\Http\Resources\Ticket\TicketResource;
use App\Models\Ticket;
use App\Services\Ticket\TicketWorkflowService;
use App\Http\Requests\Ticket\AssignTicketRequest;
use App\Http\Requests\Ticket\ReassignTicketRequest;
use App\Http\Requests\Ticket\ApproveTicketRequest;
use App\Http\Requests\Ticket\RejectTicketRequest;
use App\Http\Requests\Ticket\PendingTicketRequest;
use App\Http\Requests\Ticket\ResolveTicketRequest;
use App\Http\Requests\Ticket\CloseTicketRequest;
use App\Http\Requests\Ticket\CancelTicketRequest;
use App\Http\Requests\Ticket\EscalateTicketRequest;
use App\Http\Requests\Ticket\StartTicketRequest;
class TicketWorkflowController extends ApiController
{
public function __construct(
protected TicketWorkflowService $service
) {}
/**
* History Workflow
*/
public function history(Ticket $ticket)
{
$data = $this->service->history($ticket);
return $this->success(
$data,
'Workflow berhasil diambil'
);
}
/**
* Assign Teknisi
*/
public function assign(
AssignTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->assign(
$ticket,
$request->technicians,
$request->leader_id,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Teknisi berhasil ditugaskan'
);
}
/**
* Reassign Teknisi
*/
public function reassign(
ReassignTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->reassign(
$ticket,
$request->technicians,
$request->leader_id,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Penugasan berhasil diperbarui'
);
}
/**
* Approve
*/
public function approve(
ApproveTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->approve(
$ticket,
$request->notes,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil disetujui'
);
}
/**
* Reject
*/
public function reject(
RejectTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->reject(
$ticket,
$request->reason,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil ditolak'
);
}
/**
* Start Work
*/
public function start(
StartTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->start(
$ticket,
$request->validated(),
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Pekerjaan dimulai'
);
}
/**
* Pending
*/
public function pending(
PendingTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->pending(
$ticket,
$request->reason,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket pending'
);
}
/**
* Resume
*/
public function resume(Ticket $ticket)
{
$ticket = $this->service->resume(
$ticket,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket dilanjutkan'
);
}
/**
* Resolve
*/
public function resolve(
ResolveTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->resolve(
$ticket,
$request->notes,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil diselesaikan'
);
}
/**
* Close
*/
public function close(
CloseTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->close(
$ticket,
$request->notes,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil ditutup'
);
}
/**
* Cancel
*/
public function cancel(
CancelTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->cancel(
$ticket,
$request->reason,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil dibatalkan'
);
}
/**
* Escalate
*/
public function escalate(
EscalateTicketRequest $request,
Ticket $ticket
) {
$ticket = $this->service->escalate(
$ticket,
$request->reason,
auth()->id() ?? 1
);
return $this->success(
new TicketResource($ticket),
'Ticket berhasil dieskalasi'
);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class ApproveTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'notes' => 'nullable|string|max:1000'
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class AssignTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'technicians' => 'required|array|min:1',
'leader_id' => 'required|integer',
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class CancelTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'reason' => 'required|string|max:2000'
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class CloseTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'notes' => 'nullable|string|max:2000'
];
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class EscalateTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'reason' => 'required|string|max:2000',
'level' => 'nullable|in:L1,L2,L3,NOC'
];
}
public function messages(): array
{
return [
'reason.required' => 'Alasan eskalasi wajib diisi'
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class PendingTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'reason' => 'required|string|max:1000'
];
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class ReassignTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'technicians' => 'required|array|min:1',
'technicians.*' => 'integer',
'leader_id' => 'required|integer'
];
}
public function messages(): array
{
return [
'technicians.required' => 'Daftar teknisi wajib diisi',
'technicians.array' => 'Format teknisi harus array',
'leader_id.required' => 'Leader teknisi wajib dipilih'
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class RejectTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'reason' => 'required|string|max:1000'
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class ResolveTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'notes' => 'required|string|max:2000'
];
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Ticket;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StartTicketRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'latitude' => 'nullable|numeric',
'longitude' => 'nullable|numeric',
'notes' => 'nullable|string|max:1000'
];
}
}