feat: max file sizr

This commit is contained in:
2025-11-26 12:48:37 +03:30
parent c4abf94c57
commit 626a95dc57
+2 -23
View File
@@ -23,7 +23,7 @@ public function store(Request $request)
'image_id' => 'nullable|exists:images,id', 'image_id' => 'nullable|exists:images,id',
'duration' => 'nullable|integer', 'duration' => 'nullable|integer',
'file' => 'nullable|mimes:mp3,wav,mp4,mov|max:50480', 'file' => 'nullable|mimes:mp3,wav,mp4,mov|max:512000',
'external_url' => 'nullable|string', 'external_url' => 'nullable|string',
'visibility' => 'nullable|in:public,private', 'visibility' => 'nullable|in:public,private',
@@ -71,8 +71,6 @@ public function store(Request $request)
'media' => $media->load(['image', 'category' , 'tags']), 'media' => $media->load(['image', 'category' , 'tags']),
]); ]);
} }
// GET all visible media
public function index(Request $request) public function index(Request $request)
{ {
$query = Media::with(['image', 'category', 'myNote', 'tags']) $query = Media::with(['image', 'category', 'myNote', 'tags'])
@@ -80,18 +78,9 @@ public function index(Request $request)
$q->where('visibility', 'public') $q->where('visibility', 'public')
->orWhere('user_id', auth()->id()); ->orWhere('user_id', auth()->id());
}); });
// ----------------------------
// Filter by category_id
// ----------------------------
if ($request->filled('category')) { if ($request->filled('category')) {
$query->where('category_id', $request->category); $query->where('category_id', $request->category);
} }
// ----------------------------
// Filter by tags (multiple)
// ?tags=relax,sleep
// ----------------------------
if ($request->filled('tags')) { if ($request->filled('tags')) {
$tags = explode(',', $request->tags); $tags = explode(',', $request->tags);
@@ -99,12 +88,6 @@ public function index(Request $request)
$q->whereIn('name', $tags); $q->whereIn('name', $tags);
}); });
} }
// ----------------------------
// Global search
// ?search=sleep OR ?search=rel
// Search in: title, caption, category name, tags
// ----------------------------
if ($request->filled('search')) { if ($request->filled('search')) {
$search = $request->search; $search = $request->search;
@@ -125,10 +108,6 @@ public function index(Request $request)
}); });
}); });
} }
// ----------------------------
// Final result
// ----------------------------
return response()->json( return response()->json(
$query->orderBy('created_at', 'desc')->get() $query->orderBy('created_at', 'desc')->get()
); );
@@ -163,7 +142,7 @@ public function update(Request $request, $id)
'image_id' => 'nullable|exists:images,id', 'image_id' => 'nullable|exists:images,id',
'duration' => 'nullable|integer', 'duration' => 'nullable|integer',
'file' => 'nullable|mimes:mp3,wav,mp4,mov|max:50480', 'file' => 'nullable|mimes:mp3,wav,mp4,mov|max:512000',
'external_url' => 'nullable|string', 'external_url' => 'nullable|string',
'visibility' => 'nullable|in:public,private', 'visibility' => 'nullable|in:public,private',
'tags' => 'nullable|array', 'tags' => 'nullable|array',