fix: server saving

This commit is contained in:
Andras Bacsai 2023-10-09 20:12:03 +02:00
parent 9c22e01716
commit 3dab1eb92e

View File

@ -17,10 +17,14 @@ class Server extends BaseModel
protected static function booted() protected static function booted()
{ {
static::saving(function ($server) { static::saving(function ($server) {
$server->forceFill([ $payload = [];
'ip' => Str::of($server->ip)->trim(), if ($server->user) {
'user' => Str::of($server->user)->trim(), $payload['user'] = Str::of($server->user)->trim();
]); }
if ($server->ip) {
$payload['ip'] = Str::of($server->ip)->trim();
}
$server->forceFill($payload);
}); });
static::created(function ($server) { static::created(function ($server) {