Skip to content

Notes

當前用戶創建筆記操作

掛載功能

  • like/unlike
  • favorite/unfavorite
  • collect

CURD Resource

[PUT][AUTH][CURRENT_USER] /api/notes/:id

當前登入用戶更新自己建立的筆記。

validation

  • content: required,str

request

json
{
	"content": "1111121212"
}

response

json
{
	"data": {
		"id": 6,
		"user_id": 1,
		"content": "1111121212",
		"created_at": "2024-06-30T15:51:24.000000Z",
		"updated_at": "2024-06-30T15:53:50.000000Z",
		"deleted_at": null,
		"user": {
			"id": 1,
			"name": "h11eel",
			"username": "h11eel",
			"email": "1311311111@tt.com",
			"email_verified_at": null,
			"two_factor_secret": null,
			"two_factor_recovery_codes": null,
			"created_at": "2024-06-30T13:58:13.000000Z",
			"updated_at": "2024-06-30T13:58:13.000000Z"
		}
	}
}

[POST][AUTH][CURRENT_USER] /api/notes

當前登入用戶創建筆記。

validation

  • content: required,str

request

json
{
	"content": "121212"
}

response

json
{
	"data": {
		"content": "121212",
		"user_id": 1,
		"updated_at": "2024-06-30T15:51:24.000000Z",
		"created_at": "2024-06-30T15:51:24.000000Z",
		"id": 6
	}
}

[GET][AUTH][CURRENT_USER] /api/notes/:id

取得當前用戶創建的指定筆記。

response

json
{
	"data": {
		"id": 6,
		"user_id": 1,
		"content": "121212",
		"created_at": "2024-06-30T15:51:24.000000Z",
		"updated_at": "2024-06-30T15:51:24.000000Z",
		"deleted_at": null,
		"user": {
			"id": 1,
			"name": "h11eel",
			"username": "h11eel",
			"email": "1311311111@tt.com",
			"email_verified_at": null,
			"two_factor_secret": null,
			"two_factor_recovery_codes": null,
			"created_at": "2024-06-30T13:58:13.000000Z",
			"updated_at": "2024-06-30T13:58:13.000000Z"
		}
	}
}

[GET][AUTH][CURRENT_USER] /api/notes

取得當前用戶建立的筆記清單。

response

json
{
	"data": [
		{
			"id": 6,
			"user_id": 1,
			"content": "1111121212",
			"created_at": "2024-06-30T15:51:24.000000Z",
			"updated_at": "2024-06-30T15:53:50.000000Z",
			"deleted_at": null
		},
		{
			"id": 5,
			"user_id": 1,
			"content": "h11321ello!!",
			"created_at": "2024-06-30T14:42:44.000000Z",
			"updated_at": "2024-06-30T14:42:44.000000Z",
			"deleted_at": null
		}
	],
		"links": {
		"first": "http:\/\/nordpress-next.test\/api\/notes?page=1",
		"last": "http:\/\/nordpress-next.test\/api\/notes?page=1",
		"prev": null,
		"next": null
	},
	"meta": {
		"current_page": 1,
		"from": 1,
		"last_page": 1,
		"links": [
			{
				"url": null,
				"label": "« Previous",
				"active": false
			},
			{
				"url": "http:\/\/nordpress-next.test\/api\/notes?page=1",
				"label": "1",
				"active": true
			},
			{
				"url": null,
				"label": "Next »",
				"active": false
			}
		],
		"path": "http:\/\/nordpress-next.test\/api\/notes",
		"per_page": 10,
		"to": 6,
		"total": 6
	}
}

[DELETE][AUTH][CURRENT_USER] /api/notes/:id

刪除當前用戶創建的指定筆記。

response

HTTP_NO_CONTENT = 204

[POST][AUTH][CURRENT_USER] /api/notes/:id/likes/toggle

當前用戶對指定重點按讚/取消按讚。

response

like

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"count": 1
	}
}

unlike

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"count": 0
	}
}

[POST][AUTH][CURRENT_USER] /api/notes/:id/favorites/toggle

當前用戶對指定重點最愛/取消最愛。

response

favorite

json
{
	"data": {
		"attached": [
			1
		],
		"detached": [],
		"count": 1
	}
}

unfavorite

json
{
	"data": {
		"attached": [],
		"detached": [
			1
		],
		"count": 0
	}
}