diff --git a/app/Http/Controllers/LostGameController.php b/app/Http/Controllers/LostGameController.php new file mode 100644 index 0000000..ccabcd8 --- /dev/null +++ b/app/Http/Controllers/LostGameController.php @@ -0,0 +1,33 @@ +files('lost-games')); + } + + public function store(Request $request) + { + foreach ($request->file('files') as $file) { + $file->storeAs('lost-games', $file->getClientOriginalName(), 'public'); + } + } + + public function rename(Request $request) + { + return Storage::disk('public')->move("lost-games/$request->old_filename", "lost-games/$request->new_filename"); + } + + public function destroy($filename) + { + return Storage::disk('public')->delete("lost-games/$filename"); + } +} diff --git a/routes/api.php b/routes/api.php index 544ddd4..3b2fc0e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,6 +4,7 @@ use App\Http\Controllers\GameController; use App\Http\Controllers\CompanyController; use App\Http\Controllers\ItemController; +use App\Http\Controllers\LostGameController; use App\Http\Controllers\PublicApiController; use App\Http\Controllers\TGFileController; use App\Http\Controllers\UserController; @@ -52,4 +53,8 @@ Route::apiResource('items', ItemController::class); Route::apiResource('users', UserController::class); Route::apiResource('games', GameController::class); + Route::get('lost-games', [LostGameController::class, 'index']); + Route::post('lost-games', [LostGameController::class, 'store']); + Route::post('lost-games/rename', [LostGameController::class, 'rename']); + Route::delete('lost-games/{filename}', [LostGameController::class, 'destroy']); });