-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate eloquent-resources.md (v5.5) #384
Translate eloquent-resources.md (v5.5) #384
Conversation
b05da71
to
abba173
Compare
abba173
to
25d5706
Compare
eloquent-resources.md
Outdated
- [Conditional Relationships](#conditional-relationships) | ||
- [Adding Meta Data](#adding-meta-data) | ||
- [Resource Responses](#resource-responses) | ||
# Eloquent: API 資源 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eloquent:API 資源
eloquent-resources.md
Outdated
# Eloquent: API 資源 | ||
|
||
- [介紹](#introduction) | ||
- [產生 Resouce](#generating-resources) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
產生資源
eloquent-resources.md
Outdated
- [有條件的屬性](#conditional-attributes) | ||
- [有條件的關聯](#conditional-relationships) | ||
- [新增資料的資料](#adding-meta-data) | ||
- [Resouce 回應](#resource-responses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
資源回應
eloquent-resources.md
Outdated
|
||
When building an API, you may need a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON. | ||
當你在建構 API 時,可能會需要一個位於 Eloquent 模型和實際回傳給使用者的 JSON 回應之間的轉換層。Laravel 的 Resouce 類別可以讓你更直觀且容易的將你的模型和模型集合轉換成 JSON。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
當你在建立一個 API 時,可能會需要一個位於 Eloquent 模型和實際回傳給使用者的 JSON 回應之間的轉換層。Laravel 的資源類別可以讓你更直觀且容易的將你的模型和模型集合轉換成 JSON。
eloquent-resources.md
Outdated
|
||
To generate a resource class, you may use the `make:resource` Artisan command. By default, resources will be placed in the `app/Http/Resources` directory of your application. Resources extend the `Illuminate\Http\Resources\Json\Resource` class: | ||
你可以使用 Artisan 的 `make:resource` 指令來產生一個 Resouce 類別。預設的 Resouce 會放置於 `app/Http/Resources` 你的應用程式目錄中。Resources 會繼承 `Illuminate\Http\Resources\Json\Resource` 類別: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 「Resource」都翻譯成「資源」
- 預設的 Resouce 會放置於你的
app/Http/Resources
應用程式目錄中。
eloquent-resources.md
Outdated
@@ -569,19 +569,19 @@ Sometimes you may wish to only include certain meta data with a resource respons | |||
} | |||
} | |||
|
|||
#### Adding Meta Data When Constructing Resources | |||
#### 在建構資源時新增資料的資料 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在建構資源時新增 Meta Data 的資料
eloquent-resources.md
Outdated
|
||
You may also add top-level data when constructing resource instances in your route or controller. The `additional` method, which is available on all resources, accepts an array of data that should be added to the resource response: | ||
在你的路由或控制器建構 Resource 實例時,你也可以新增最上層的資料。`additional` 方法在所有的 Resource 都可以用,並接受應該被新增到 Resource 回應的資料陣列: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「Resource」都翻譯成「資源」
eloquent-resources.md
Outdated
|
||
As you have already read, resources may be returned directly from routes and controllers: | ||
正如你已讀過的,Resource 可以從路由或控制器中回傳: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「Resource」都翻譯成「資源」
eloquent-resources.md
Outdated
@@ -601,7 +601,7 @@ However, sometimes you may need to customize the outgoing HTTP response before i | |||
->header('X-Value', 'True'); | |||
}); | |||
|
|||
Alternatively, you may define a `withResponse` method within the resource itself. This method will be called when the resource is returned as the outer-most resource in a response: | |||
或者是你可以在 Resource 中定義 `withResponse` 方法。這個方法會在 Resource 作為回應中的最外層時被呼叫: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「Resource」都翻譯成「資源」
eloquent-resources.md
Outdated
- [分頁](#pagination) | ||
- [有條件的屬性](#conditional-attributes) | ||
- [有條件的關聯](#conditional-relationships) | ||
- [新增資料的資料](#adding-meta-data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增 Meta Data
Translate
eloquent-resources.md
(v5.5)resources
都沒翻,但有點想翻meta-
的翻譯則是參照 google 找到的用法,像是meta data
,會是資料的資料。