diff --git a/app/Filament/Resources/TokenResource.php b/app/Filament/Resources/TokenResource.php index baa9332f..cf831ae6 100644 --- a/app/Filament/Resources/TokenResource.php +++ b/app/Filament/Resources/TokenResource.php @@ -21,10 +21,22 @@ class TokenResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-key'; - // tambahkan ini supaya muncul di MANAGEMENT protected static ?int $navigationSort = 5; - protected static ?string $navigationGroup = 'Management'; - protected static ?string $navigationLabel = 'Tokens'; + + protected static function getNavigationLabel(): string + { + return __('Tokens'); + } + + public static function getPluralLabel(): ?string + { + return static::getNavigationLabel(); + } + + protected static function getNavigationGroup(): ?string + { + return __('Management'); + } public static function form(Form $form): Form { diff --git a/app/Http/Controllers/Api/TicketController.php b/app/Http/Controllers/Api/TicketController.php new file mode 100644 index 00000000..11e79ed5 --- /dev/null +++ b/app/Http/Controllers/Api/TicketController.php @@ -0,0 +1,56 @@ +find($id); + + if (! $ticket) { + return response()->json([ + 'message' => 'Ticket not found', + ], 404); + } + + return $this->formatTicketResponse($ticket); + } + + /** + * Format response JSON untuk ticket + */ + protected function formatTicketResponse(Ticket $ticket) + { + $content = $ticket->content; + + // Ganti
dan

jadi newline sebelum strip_tags + $content = preg_replace('//i', "\n", $content); + $content = preg_replace('/<\/p>/i', "\n", $content); + + // Hapus semua tag HTML lain + $plainText = trim(strip_tags($content)); + + return response()->json([ + 'message' => 'Success', + 'data' => [ + 'tiket_id' => $ticket->id, + 'tiket_code' => $ticket->code, + 'tiket_status' => $ticket->status?->name, + 'tiket_nama' => $ticket->name, + 'tiket_layanan' => $ticket->project?->name, + 'tiket_deskripsi' => $plainText, + 'tiket_created_at' => $ticket->created_at?->format('Y-m-d H:i:s'), + 'tiket_updated_at' => $ticket->updated_at?->format('Y-m-d H:i:s'), + ], + ]); + } +} diff --git a/lang/id.json b/lang/id.json index 2fbb31ae..13496a04 100644 --- a/lang/id.json +++ b/lang/id.json @@ -290,5 +290,6 @@ "End year": "Tahun akhir", "Month": "Bulan", "Year": "Tahun", - "Data not found": "Data tidak ditemukan" + "Data not found": "Data tidak ditemukan", + "Tokens": "Token" } diff --git a/routes/api.php b/routes/api.php index d3e8a4b5..afaf194d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -31,3 +31,5 @@ // 'user' => $request->user(), // ]); // }); + +Route::middleware('auth:sanctum')->get('/ticket/id/{id}', [\App\Http\Controllers\Api\TicketController::class, 'show']);