Skip to content

Commit 969484f

Browse files
committed
enhance: Set default preferred language during user creation if not provided
1 parent f4b6eb4 commit 969484f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/Models/Concerns/CmsUserTrait.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ trait CmsUserTrait
2020
use HasRoles;
2121
use Notifiable;
2222

23+
public static function bootCmsUserTrait()
24+
{
25+
static::creating(function (self $model) {
26+
// Fill "preferred_language" if empty
27+
if (blank($model->preferred_language)) {
28+
$model->preferred_language = config('app.locale') ?? app()->getLocale();
29+
}
30+
});
31+
}
32+
2333
public function canAccessPanel(Panel $panel): bool
2434
{
2535
return true;
@@ -272,16 +282,4 @@ public function isLocked(): Attribute
272282
);
273283
}
274284
// endregion Attributes
275-
276-
public static function boot()
277-
{
278-
parent::boot();
279-
280-
static::creating(function (self $model) {
281-
// Fill "preferred_language" if empty
282-
if (blank($model->preferred_language)) {
283-
$model->preferred_language = config('app.locale') ?? app()->getLocale();
284-
}
285-
});
286-
}
287285
}

0 commit comments

Comments
 (0)