You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 27, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ That's all, you are now good to go.
32
32
33
33
# Usage
34
34
35
-
First you need to make sure that the translatable attributes has a mysql field type of TEXT, if you are building the database from a migration file you may do this:
35
+
First you need to make sure that the translatable attributes has a mysql field type of text or json, if you are building the database from a migration file you may do this:
36
36
37
37
```php
38
38
<?php
@@ -55,11 +55,13 @@ class Country extends Model
55
55
56
56
protected $table = 'countries';
57
57
public $translatable = ['name'];
58
+
public $casts = ['name' => 'array'];
58
59
}
59
60
```
60
61
61
62
- Add the `Translatable` trait to your model class
62
63
- Add a public class property `$translatable` as an array that holds the names of the translatable fields in your model.
64
+
- Remember to cast the translatable attribute as 'array' in the `$casts` property of the model.
63
65
64
66
Now our model has the `name` attribute translatable, so on creating a new Model you may specify the name field as follow:
0 commit comments