Comment

Endpoint untuk mengelola data comment. Semua endpoint bersifat publik dan tidak memerlukan autentikasi.


Response 200 — Berhasil
{
  "success": true,
  "message": "Data comment ditemukan",
  "data": [
    {
      "id": 1,
      "post_id": 1,
      "name": "Komentator",
      "email": "komentar@example.com",
      "body": "Isi komentar",
      "status": "approved",
      "created_at": "2024-01-01T00:00:00.000000Z",
      "updated_at": "2024-01-01T00:00:00.000000Z"
    }
  ]
}

Response 200 — Berhasil
{
  "success": true,
  "message": "Data comment ditemukan",
  "data": {
    "id": 1,
    "post_id": 1,
    "name": "Komentator",
    "email": "komentar@example.com",
    "body": "Isi komentar",
    "status": "approved",
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-01-01T00:00:00.000000Z",
    "post": {
      "id": 1,
      "title": "Judul Post",
      "body": "Isi konten post...",
      "author": "Nama Penulis",
      "slug": "judul-post",
      "status": "published"
    }
  }
}
Response 404 — Comment Tidak Ditemukan
{
  "success": false,
  "message": "Data tidak ditemukan",
  "errors": {}
}

Response 200 — Berhasil
{
  "success": true,
  "message": "Data comment ditemukan",
  "data": [
    {
      "id": 1,
      "post_id": 1,
      "name": "Komentator",
      "email": "komentar@example.com",
      "body": "Isi komentar",
      "status": "approved",
      "created_at": "2024-01-01T00:00:00.000000Z",
      "updated_at": "2024-01-01T00:00:00.000000Z"
    }
  ]
}
Response 404 — Post Tidak Ditemukan
{
  "success": false,
  "message": "Data tidak ditemukan",
  "errors": {}
}

Request Body
{
  "post_id": 1,
  "name": "Komentator",
  "email": "komentar@example.com",
  "body": "Isi komentar",
  "status": "pending"
}
Response 201 — Berhasil Dibuat
{
  "success": true,
  "message": "Comment berhasil dibuat",
  "data": {
    "id": 1,
    "post_id": 1,
    "name": "Komentator",
    "email": "komentar@example.com",
    "body": "Isi komentar",
    "status": "pending",
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-01-01T00:00:00.000000Z"
  }
}
Response 422 — Validasi Gagal
{
  "success": false,
  "message": "Data tidak valid",
  "errors": {
    "post_id": ["The selected post id is invalid."],
    "body": ["The body field is required."]
  }
}

Request Body
{
  "name": "Komentator Diperbarui",
  "email": "baru@example.com",
  "body": "Isi komentar yang diperbarui",
  "status": "approved"
}
Response 200 — Berhasil Diperbarui
{
  "success": true,
  "message": "Comment berhasil diperbarui",
  "data": {
    "id": 1,
    "post_id": 1,
    "name": "Komentator Diperbarui",
    "email": "baru@example.com",
    "body": "Isi komentar yang diperbarui",
    "status": "approved",
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-01-01T00:00:00.000000Z"
  }
}
Response 404 — Comment Tidak Ditemukan
{
  "success": false,
  "message": "Data tidak ditemukan",
  "errors": {}
}

Response 200 — Berhasil Dihapus
{
  "success": true,
  "message": "Comment berhasil dihapus",
  "data": {}
}
Response 404 — Comment Tidak Ditemukan
{
  "success": false,
  "message": "Data tidak ditemukan",
  "errors": {}
}