Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alihardan committed Jun 26, 2024
1 parent c7aa75a commit 9d574b7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/Http/Controllers/LostGameController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class LostGameController extends Controller
{


public function index()
{
return str_replace("lost-games/", "", Storage::disk('public')->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");
}
}
5 changes: 5 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);
});

0 comments on commit 9d574b7

Please sign in to comment.