baseName . '-' . uniqid() . '.' . $file->extension; $file->saveAs('../../frontend/web/uploads/' . $file_name); $model->$champs = $file_name; } else { $model->$champs = $filename_old; } $model->save(); } }