fix: add svg format
This commit is contained in:
@@ -15,7 +15,7 @@ protected function fileFields(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'sound' => ['column' => 'sound_path', 'folder' => 'background-sounds/sounds', 'rules' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:102400'],
|
'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'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ protected function fileFields(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'sound' => ['column' => 'sound_path', 'folder' => 'bells/sounds', 'rules' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:51200'],
|
'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'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public function store(Request $request)
|
|||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'name' => 'required|string|max:255|unique:categories,name',
|
'name' => 'required|string|max:255|unique:categories,name',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'icon' => 'nullable|image|max:8192',
|
'icon' => 'nullable|file|extensions:jpg,jpeg,png,gif,webp,bmp,svg|max:8192',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$category = Category::create([
|
$category = Category::create([
|
||||||
@@ -60,7 +60,7 @@ public function update(Request $request, $id)
|
|||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'name' => 'sometimes|string|max:255|unique:categories,name,' . $category->id,
|
'name' => 'sometimes|string|max:255|unique:categories,name,' . $category->id,
|
||||||
'description' => 'nullable|string',
|
'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)) {
|
if (array_key_exists('name', $data)) {
|
||||||
|
|||||||
@@ -4,21 +4,24 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Image;
|
use App\Models\Image;
|
||||||
|
use App\Traits\StoresUploads;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ImageController extends Controller
|
class ImageController extends Controller
|
||||||
{
|
{
|
||||||
|
use StoresUploads;
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$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',
|
'title' => 'nullable|string|max:255',
|
||||||
'description' => 'nullable|string|max:500',
|
'description' => 'nullable|string|max:500',
|
||||||
'type' => 'nullable|in:public,private',
|
'type' => 'nullable|in:public,private',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$path = $request->file('image')->store('images', 'public');
|
$path = $this->storeUpload($request->file('image'), 'images');
|
||||||
|
|
||||||
$image = Image::create([
|
$image = Image::create([
|
||||||
'user_id' => auth()->id(),
|
'user_id' => auth()->id(),
|
||||||
@@ -83,7 +86,7 @@ public function update(Request $request, $id)
|
|||||||
'title' => 'nullable|string|max:255',
|
'title' => 'nullable|string|max:255',
|
||||||
'description' => 'nullable|string|max:500',
|
'description' => 'nullable|string|max:500',
|
||||||
'type' => 'nullable|in:public,private',
|
'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')) {
|
if ($request->hasFile('image')) {
|
||||||
@@ -91,7 +94,7 @@ public function update(Request $request, $id)
|
|||||||
Storage::disk('public')->delete($image->path);
|
Storage::disk('public')->delete($image->path);
|
||||||
|
|
||||||
// store new one
|
// store new one
|
||||||
$path = $request->file('image')->store('images', 'public');
|
$path = $this->storeUpload($request->file('image'), 'images');
|
||||||
$image->path = $path;
|
$image->path = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public function store(Request $request)
|
|||||||
'subcategory_ids' => 'nullable|array',
|
'subcategory_ids' => 'nullable|array',
|
||||||
'subcategory_ids.*' => 'integer|exists:sub_categories,id',
|
'subcategory_ids.*' => 'integer|exists:sub_categories,id',
|
||||||
'image_id' => 'nullable|exists:images,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',
|
'duration' => 'nullable|integer',
|
||||||
'is_premium' => 'nullable|boolean',
|
'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',
|
'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',
|
'subcategory_ids.*' => 'integer|exists:sub_categories,id',
|
||||||
'is_premium' => 'nullable|boolean',
|
'is_premium' => 'nullable|boolean',
|
||||||
'image_id' => 'nullable|exists:images,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',
|
'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',
|
'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',
|
'external_url' => 'nullable|string',
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public function store(Request $request)
|
|||||||
'file' => 'required|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520',
|
'file' => 'required|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520',
|
||||||
'type' => 'nullable|in:public,private',
|
'type' => 'nullable|in:public,private',
|
||||||
'image_id' => 'nullable|exists:images,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',
|
||||||
'playlist_id' => 'nullable|exists:music_playlists,id', // single (backward compatible)
|
'playlist_id' => 'nullable|exists:music_playlists,id', // single (backward compatible)
|
||||||
'playlist_ids' => 'nullable|array', // multiple
|
'playlist_ids' => 'nullable|array', // multiple
|
||||||
'playlist_ids.*' => 'integer|exists:music_playlists,id',
|
'playlist_ids.*' => 'integer|exists:music_playlists,id',
|
||||||
@@ -241,7 +241,7 @@ public function update(Request $request, $id)
|
|||||||
'type' => 'nullable|in:public,private',
|
'type' => 'nullable|in:public,private',
|
||||||
'file' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520',
|
'file' => 'nullable|file|extensions:mp3,wav,ogg,flac,aac,m4a,opus,mpga,wma|max:20971520',
|
||||||
'image_id' => 'nullable|exists:images,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|min:1',
|
'duration' => 'nullable|integer|min:1',
|
||||||
'is_active' => 'nullable|boolean',
|
'is_active' => 'nullable|boolean',
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public function store(Request $request)
|
|||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
'order' => 'nullable|integer',
|
'order' => 'nullable|integer',
|
||||||
'is_active' => 'nullable|boolean',
|
'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',
|
'video' => 'nullable|mimes:mp4,mov,webm|max:512000',
|
||||||
'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200',
|
'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200',
|
||||||
]);
|
]);
|
||||||
@@ -105,7 +105,7 @@ public function update(Request $request, $id)
|
|||||||
'name' => 'sometimes|string|max:255',
|
'name' => 'sometimes|string|max:255',
|
||||||
'order' => 'nullable|integer',
|
'order' => 'nullable|integer',
|
||||||
'is_active' => 'nullable|boolean',
|
'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',
|
'video' => 'nullable|mimes:mp4,mov,webm|max:512000',
|
||||||
'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200',
|
'sound' => 'nullable|mimes:mp3,wav,ogg,flac|max:51200',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user