-
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-serialization.md (v5.5) #381
Translate eloquent-serialization.md (v5.5) #381
Conversation
eloquent-serialization.md
Outdated
- [序列化成陣列](#serializing-to-arrays) | ||
- [序列化成 JSON](#serializing-to-json) | ||
- [從 JSON 隱藏屬性](#hiding-attributes-from-json) | ||
- [附值到 JSON](#appending-values-to-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.
「附值」有點太濃縮 XD -> 「將值附加到 JSON」
eloquent-serialization.md
Outdated
|
||
When building JSON APIs, you will often need to convert your models and relationships to arrays or JSON. Eloquent includes convenient methods for making these conversions, as well as controlling which attributes are included in your serializations. | ||
建構 JSON API 時,你經常會需要將模型和關聯轉換成陣列或 JSON。Eloquent 已包含了這些用來轉換的方便方法,以及控制序列化中應該包含哪些屬性。 |
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 已經包含了這些用來轉換的方便方法,以及控制序列化中應該包含哪些屬性。
eloquent-serialization.md
Outdated
* | ||
* @var array | ||
*/ | ||
protected $hidden = ['password']; | ||
} | ||
|
||
> {note} When hiding relationships, use the relationship's method name. | ||
> {note} 隱藏關聯時,請使用關聯的方法名稱。 |
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-serialization.md
Outdated
* | ||
* @var array | ||
*/ | ||
protected $visible = ['first_name', 'last_name']; | ||
} | ||
|
||
#### Temporarily Modifying Attribute Visibility | ||
#### 暫時修改屬性的能見度 |
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-serialization.md
Outdated
|
||
return $user->makeHidden('attribute')->toArray(); | ||
|
||
<a name="appending-values-to-json"></a> | ||
## Appending Values To JSON | ||
## 附值到 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.
將值附加到 JSON
eloquent-serialization.md
Outdated
|
||
Occasionally, when casting models to an array or JSON, you may wish to add attributes that do not have a corresponding column in your database. To do so, first define an [accessor](/docs/{{version}}/eloquent-mutators) for the value: | ||
有時將模型轉換成陣列或 JSON 的時候,你可能希望在資料庫中新增沒有相應欄位的屬性。要達到此目的,首先為這個值定義 [存取器](/docs/{{version}}/eloquent-mutators): |
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.
有時候,將模型轉換為陣列或JSON 時,你可能希望在資料庫中新增沒有相應欄位的屬性。要達到此目的,首先為這個值定義存取器:
Translate
eloquent-serialization.md
(v5.5)