CRUD Ticket Insidace Type

This commit is contained in:
Wian Drs
2026-06-25 13:06:24 +07:00
parent faab64e0dd
commit ad472a9880
10 changed files with 338 additions and 0 deletions
@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers\Ticket;
use App\Http\Controllers\ApiController;
use App\Models\TicketIncidentType;
use Illuminate\Http\JsonResponse;
use App\Services\Ticket\TicketIncidentTypeService;
use App\Http\Resources\TicketIncidentType\TicketIncidentTypeResource;
use App\Http\Requests\TicketIncidentType\StoreTicketIncidentTypeRequest;
use App\Http\Requests\TicketIncidentType\UpdateTicketIncidentTypeRequest;
class TicketIncidentTypeController extends ApiController
{
public function __construct(
private TicketIncidentTypeService $service
) {}
public function index(): JsonResponse
{
return $this->success(
TicketIncidentTypeResource::collection(
$this->service->getAll()
)
);
}
public function store(
StoreTicketIncidentTypeRequest $request
): JsonResponse {
$incidentType = $this->service->create(
$request->validated()
);
return $this->created(
new TicketIncidentTypeResource($incidentType),
'Incident Type berhasil dibuat'
);
}
public function show(
TicketIncidentType $ticketIncidentType
): JsonResponse {
return $this->success(
new TicketIncidentTypeResource(
$ticketIncidentType
)
);
}
public function update(
UpdateTicketIncidentTypeRequest $request,
TicketIncidentType $ticketIncidentType
): JsonResponse {
$incidentType = $this->service->update(
$ticketIncidentType,
$request->validated()
);
return $this->updated(
new TicketIncidentTypeResource($incidentType),
'Incident Type berhasil diupdate'
);
}
public function destroy(
TicketIncidentType $ticketIncidentType
): JsonResponse {
$this->service->delete(
$ticketIncidentType
);
return $this->deleted(
'Incident Type berhasil dihapus'
);
}
}