- 'created_by' => $userId,
- 'updated_by' => $userId
- ]);
+ 'uploaded_to' => $uploadedTo
+ ];
+
+ if (auth()->user() && auth()->user()->id !== 0) {
+ $userId = auth()->user()->id;
+ $imageDetails['created_by'] = $userId;
+ $imageDetails['updated_by'] = $userId;
+ }
+
+ $image = Image::forceCreate($imageDetails);