From 835cba22ed05e2d12ca5334d8bd92544d2bc9851 Mon Sep 17 00:00:00 2001 From: AmirmahdiNourkazemi Date: Sat, 6 Jun 2026 16:38:01 +0330 Subject: [PATCH] fix: add svg format --- app/Http/Controllers/BackgroundSoundController.php | 2 +- app/Http/Controllers/BellSoundController.php | 2 +- app/Http/Controllers/CategoryController.php | 4 ++-- app/Http/Controllers/ImageController.php | 11 +++++++---- app/Http/Controllers/MediaController.php | 4 ++-- app/Http/Controllers/MusicController.php | 4 ++-- app/Http/Controllers/SceneController.php | 4 ++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/BackgroundSoundController.php b/app/Http/Controllers/BackgroundSoundController.php index 83bbc26..a182a46 100644 --- a/app/Http/Controllers/BackgroundSoundController.php +++ b/app/Http/Controllers/BackgroundSoundController.php @@ -15,7 +15,7 @@ protected function fileFields(): array { return [ 'sound' => ['column' => 'sound_path', 'folder' => 'background-sounds/sounds', 'rules' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:102400'], - 'image' => ['column' => 'image_path', 'folder' => 'background-sounds/images', 'rules' => 'nullable|image|max:8192'], + 'image' => ['column' => 'image_path', 'folder' => 'background-sounds/images', 'rules' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192'], ]; } } diff --git a/app/Http/Controllers/BellSoundController.php b/app/Http/Controllers/BellSoundController.php index d25cb3e..03a9c35 100644 --- a/app/Http/Controllers/BellSoundController.php +++ b/app/Http/Controllers/BellSoundController.php @@ -15,7 +15,7 @@ protected function fileFields(): array { return [ 'sound' => ['column' => 'sound_path', 'folder' => 'bells/sounds', 'rules' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:51200'], - 'image' => ['column' => 'image_path', 'folder' => 'bells/images', 'rules' => 'nullable|image|max:8192'], + 'image' => ['column' => 'image_path', 'folder' => 'bells/images', 'rules' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192'], ]; } } diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 3d76e01..196254b 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -29,7 +29,7 @@ public function store(Request $request) $data = $request->validate([ 'name' => 'required|string|max:255|unique:categories,name', 'description' => 'nullable|string', - 'icon' => 'nullable|image|max:8192', + 'icon' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', ]); $category = Category::create([ @@ -60,7 +60,7 @@ public function update(Request $request, $id) $data = $request->validate([ 'name' => 'sometimes|string|max:255|unique:categories,name,' . $category->id, 'description' => 'nullable|string', - 'icon' => 'nullable|image|max:8192', + 'icon' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', ]); if (array_key_exists('name', $data)) { diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index b55490a..8f36912 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -4,21 +4,24 @@ namespace App\Http\Controllers; use App\Models\Image; +use App\Traits\StoresUploads; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; class ImageController extends Controller { + use StoresUploads; + public function store(Request $request) { $data = $request->validate([ - 'image' => 'required|image|max:2048', + 'image' => 'required|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'title' => 'nullable|string|max:255', 'description' => 'nullable|string|max:500', 'type' => 'nullable|in:public,private', ]); - $path = $request->file('image')->store('images', 'public'); + $path = $this->storeUpload($request->file('image'), 'images'); $image = Image::create([ 'user_id' => auth()->id(), @@ -83,7 +86,7 @@ public function update(Request $request, $id) 'title' => 'nullable|string|max:255', 'description' => 'nullable|string|max:500', 'type' => 'nullable|in:public,private', - 'image' => 'nullable|image|max:2048', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', ]); if ($request->hasFile('image')) { @@ -91,7 +94,7 @@ public function update(Request $request, $id) Storage::disk('public')->delete($image->path); // store new one - $path = $request->file('image')->store('images', 'public'); + $path = $this->storeUpload($request->file('image'), 'images'); $image->path = $path; } diff --git a/app/Http/Controllers/MediaController.php b/app/Http/Controllers/MediaController.php index c740e00..56388ca 100644 --- a/app/Http/Controllers/MediaController.php +++ b/app/Http/Controllers/MediaController.php @@ -29,7 +29,7 @@ public function store(Request $request) 'subcategory_ids' => 'nullable|array', 'subcategory_ids.*' => 'integer|exists:sub_categories,id', 'image_id' => 'nullable|exists:images,id', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'duration' => 'nullable|integer', 'is_premium' => 'nullable|boolean', 'file' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma,mp4,mov,m4v,webm,mkv,avi,3gp|max:512000', @@ -481,7 +481,7 @@ public function update(Request $request, $id) 'subcategory_ids.*' => 'integer|exists:sub_categories,id', 'is_premium' => 'nullable|boolean', 'image_id' => 'nullable|exists:images,id', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'duration' => 'nullable|integer', 'file' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma,mp4,mov,m4v,webm,mkv,avi,3gp|max:512000', 'external_url' => 'nullable|string', diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php index b057ddb..6680d04 100644 --- a/app/Http/Controllers/MusicController.php +++ b/app/Http/Controllers/MusicController.php @@ -138,7 +138,7 @@ public function store(Request $request) 'file' => 'required|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520', 'type' => 'nullable|in:public,private', 'image_id' => 'nullable|exists:images,id', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'playlist_id' => 'nullable|exists:music_playlists,id', // single (backward compatible) 'playlist_ids' => 'nullable|array', // multiple 'playlist_ids.*' => 'integer|exists:music_playlists,id', @@ -241,7 +241,7 @@ public function update(Request $request, $id) 'type' => 'nullable|in:public,private', 'file' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520', 'image_id' => 'nullable|exists:images,id', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'duration' => 'nullable|integer|min:1', 'is_active' => 'nullable|boolean', ]); diff --git a/app/Http/Controllers/SceneController.php b/app/Http/Controllers/SceneController.php index 1b83686..be5c0b6 100644 --- a/app/Http/Controllers/SceneController.php +++ b/app/Http/Controllers/SceneController.php @@ -76,7 +76,7 @@ public function store(Request $request) 'name' => 'required|string|max:255', 'order' => 'nullable|integer', 'is_active' => 'nullable|boolean', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'video' => 'nullable|mimes:mp4,mov,webm|max:512000', 'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200', ]); @@ -105,7 +105,7 @@ public function update(Request $request, $id) 'name' => 'sometimes|string|max:255', 'order' => 'nullable|integer', 'is_active' => 'nullable|boolean', - 'image' => 'nullable|image|max:8192', + 'image' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192', 'video' => 'nullable|mimes:mp4,mov,webm|max:512000', 'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200', ]);