This commit is contained in:
2026-06-03 12:11:28 +03:30
parent bae1a2acb0
commit 0cb4954579
6 changed files with 51 additions and 15 deletions
+4 -1
View File
@@ -4,6 +4,7 @@
use App\Models\Image;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
trait HandlesImageUpload
{
@@ -18,7 +19,9 @@ protected function uploadedImageId(Request $request, string $field = 'image'): ?
return null;
}
$path = $request->file($field)->store('images', 'public');
$file = $request->file($field);
$ext = $file->getClientOriginalExtension() ?: ($file->guessExtension() ?: 'jpg');
$path = $file->storeAs('images', Str::random(40) . '.' . $ext, 'public');
return Image::create([
'user_id' => auth()->id(),