fix(models): replace forceCreate with forceFill+save pattern

Replaces Model::forceCreate([...]) calls with (new Model)->forceFill([...])->save()
across SettingsBackup, Server, and User models to avoid bypassing Eloquent
model event lifecycle during record creation.
This commit is contained in:
Andras Bacsai committed 2026-03-31 13:50:37 +02:00
1 parent 1a603a10ed
commit a77e1f47d1
3 files changed
+13 -9

No files matched your search

+6 -6
View File
@@ -143,28 +143,28 @@ class Server extends BaseModel
}
});
static::created(function ($server) {
ServerSetting::forceCreate([
ServerSetting::create([
'server_id' => $server->id,
]);
if ($server->id === 0) {
if ($server->isSwarm()) {
SwarmDocker::forceCreate([
(new SwarmDocker)->forceFill([
'id' => 0,
'name' => 'coolify',
'network' => 'coolify-overlay',
'server_id' => $server->id,
]);
])->save();
} else {
StandaloneDocker::forceCreate([
(new StandaloneDocker)->forceFill([
'id' => 0,
'name' => 'coolify',
'network' => 'coolify',
'server_id' => $server->id,
]);
])->saveQuietly();
}
} else {
if ($server->isSwarm()) {
SwarmDocker::forceCreate([
SwarmDocker::create([
'name' => 'coolify-overlay',
'network' => 'coolify-overlay',
'server_id' => $server->id,