1 | <?php |
||
13 | trait Translatable |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | public static function bootTranslatable() |
||
27 | |||
28 | /** |
||
29 | * Initialize a translatable model. |
||
30 | * |
||
31 | * @return void |
||
32 | */ |
||
33 | public function initializeTranslatable() |
||
42 | |||
43 | /** |
||
44 | * Get the list of non translatable fields. |
||
45 | * |
||
46 | * @return array |
||
47 | */ |
||
48 | public function getNonTranslatable() |
||
52 | |||
53 | /** |
||
54 | * Get the list of fields to duplicate on create. |
||
55 | * (Other fields MUST BE nullable in database) |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public function getOnCreateTranslatable() |
||
63 | |||
64 | /** |
||
65 | * Translation relationship. |
||
66 | * |
||
67 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
68 | */ |
||
69 | public function translation() |
||
73 | |||
74 | /** |
||
75 | * Return current item translations. |
||
76 | * |
||
77 | * @return \Illuminate\Database\Eloquent\Collection |
||
78 | */ |
||
79 | public function translations() |
||
88 | |||
89 | /** |
||
90 | * Create and return a translation entry for given locale ID. |
||
91 | * |
||
92 | * @param int $localeId |
||
93 | * @return \BBS\Nova\Translation\Models\Translation |
||
94 | */ |
||
95 | public function upsertTranslationEntry(int $localeId, int $translationId = 0) |
||
111 | |||
112 | /** |
||
113 | * Return next fresh translation ID. |
||
114 | * |
||
115 | * @return int |
||
116 | */ |
||
117 | public function freshTranslationId() |
||
128 | |||
129 | /** |
||
130 | * Scope a query to only retrieve items from given locale. |
||
131 | * |
||
132 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
133 | * @param string $iso |
||
134 | * @return \Illuminate\Database\Eloquent\Builder |
||
135 | * @throws \Exception |
||
136 | */ |
||
137 | public function scopeLocale(Builder $builder, string $iso = '') |
||
156 | } |
||
157 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: