---
# System prepended metadata

title: API 練習

---

# API 練習


## Laravel 8.x 官方文件(英文版較繁中新)
[https://laravel.com/docs/8.x](https://laravel.com/docs/8.x)
- 剛好8.x社群有簡中翻譯：[https://learnku.com/docs/laravel/8.x](https://learnku.com/docs/laravel/8.x)

## 設計稿
![](https://i.imgur.com/3hzCRjm.png)


```
GET /api/v1/collections/0
```

## 關於Response
(PHP不能直接使用完整的JSON格式，Object"{key:value}"部分需改成"[key=>value]")

- 範例：
```json=
{
    "id": 0,
    "title": "親子步道",
    "subTitle": "老少咸宜，生活好去處",
    "bgColor": "yellow",
    "iconImage": "https://example.com/uploads/images/collection/0/icon.png",
    "trails": [
        {
            "id": 0,
            "title": "冷水坑步道",
            "location": "台北市士林區",
            "distance": 600,
            "coverImage": "https://example.com/uploads/images/trail/0/cover.jpg"
        },
        {
            "id": 1,
            "title": "東吳大學登山步道",
            "location": "台北市士林區",
            "distance": 3824,
            "coverImage": "https://example.com/uploads/images/trail/1/cover.jpg"
        },
        {
            "id": 2,
            "title": "二子坪步道",
            "location": "新北市三芝區",
            "distance": 3600,
            "coverImage": "https://example.com/uploads/images/trail/2/cover.jpg"
        }
    ]
}
```

## 資料表設計
ERD(早期) => UML class diagram(較新、易讀,更物件導向Object Oriented)，可用工具如StarUML



