2FAuth/app/Api/v1/Controllers/IconController.php
2022-07-20 13:41:28 +02:00

44 lines
1016 B
PHP

<?php
namespace App\Api\v1\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Controller;
class IconController extends Controller
{
/**
* Handle uploaded icon image
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function upload(Request $request)
{
$this->validate($request, [
'icon' => 'required|image',
]);
$path = $request->file('icon')->store('public/icons');
$path = $request->file('icon')->store('', 'icons');
$response['filename'] = pathinfo($path)['basename'];
return response()->json($response, 201);
}
/**
* delete an icon
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function delete($icon)
{
Storage::disk('icons')->delete($icon);
return response()->json(null, 204);
}
}