1 | <?php |
||
13 | trait Translatable |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | public static function bootTranslatable() |
||
27 | |||
28 | /** |
||
29 | * Get the list of non translatable fields. |
||
30 | * |
||
31 | * @return array |
||
32 | */ |
||
33 | public function getNonTranslatable() |
||
37 | |||
38 | /** |
||
39 | * Get the list of fields to duplicate on create. |
||
40 | * (Other fields MUST BE nullable in database). |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | public function getOnCreateTranslatable() |
||
48 | |||
49 | /** |
||
50 | * Translation relationship. |
||
51 | * |
||
52 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
53 | */ |
||
54 | public function translation() |
||
58 | |||
59 | /** |
||
60 | * Return current item translations. |
||
61 | * |
||
62 | * @return \Illuminate\Database\Eloquent\Collection |
||
63 | */ |
||
64 | public function translations() |
||
73 | |||
74 | /** |
||
75 | * Create and return a translation entry for given locale ID. |
||
76 | * |
||
77 | * @param int $localeId |
||
78 | * @return \BBS\Nova\Translation\Models\Translation |
||
79 | */ |
||
80 | public function upsertTranslationEntry(int $localeId, int $translationId = 0) |
||
96 | |||
97 | /** |
||
98 | * Return next fresh translation ID. |
||
99 | * |
||
100 | * @return int |
||
101 | */ |
||
102 | public function freshTranslationId() |
||
113 | |||
114 | /** |
||
115 | * Scope a query to only retrieve items from given locale. |
||
116 | * |
||
117 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
118 | * @param string $iso |
||
119 | * @return \Illuminate\Database\Eloquent\Builder |
||
120 | * @throws \Exception |
||
121 | */ |
||
122 | public function scopeLocale(Builder $builder, string $iso = '') |
||
141 | } |
||
142 |
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: