This repository was archived by the owner on Jun 18, 2019. It is now read-only.
File tree 1 file changed +8
-30
lines changed
1 file changed +8
-30
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ trait Translatable
14
14
15
15
protected $ defaultLocale ;
16
16
17
+ public static function bootTranslatable (): void
18
+ {
19
+ static ::saved (function (Model $ model ) {
20
+ /* @var Translatable $model */
21
+ return $ model ->saveTranslations ();
22
+ });
23
+ }
24
+
17
25
/**
18
26
* Alias for getTranslation().
19
27
*
@@ -245,36 +253,6 @@ public function setAttribute($key, $value)
245
253
return $ this ;
246
254
}
247
255
248
- /**
249
- * @param array $options
250
- *
251
- * @return bool
252
- */
253
- public function save (array $ options = [])
254
- {
255
- if ($ this ->exists && ! $ this ->isDirty ()) {
256
- // If $this->exists and not dirty, parent::save() skips saving and returns
257
- // false. So we have to save the translations
258
- if ($ this ->fireModelEvent ('saving ' ) === false ) {
259
- return false ;
260
- }
261
-
262
- if ($ saved = $ this ->saveTranslations ()) {
263
- $ this ->fireModelEvent ('saved ' , false );
264
- $ this ->fireModelEvent ('updated ' , false );
265
- }
266
-
267
- return $ saved ;
268
- }
269
-
270
- // We save the translations only if the instance is saved in the database.
271
- if (parent ::save ($ options )) {
272
- return $ this ->saveTranslations ();
273
- }
274
-
275
- return false ;
276
- }
277
-
278
256
/**
279
257
* @param string $locale
280
258
*
You can’t perform that action at this time.
0 commit comments