Files
sam-manage/app/Http/Controllers/AppVersionController.php
권혁성 daaa77badc feat:앱버전 슈퍼관리자 소프트삭제 목록 표시, 복구/영구삭제 기능
- 슈퍼관리자: 삭제된 항목 빨간 배경으로 표시, 복구/영구삭제 버튼
- 소프트 삭제 시 APK 파일 유지, 영구 삭제 시에만 파일 제거
- restore, forceDestroy 라우트 및 서비스 메서드 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:39:19 +09:00

95 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Services\AppVersionService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class AppVersionController extends Controller
{
public function __construct(
private readonly AppVersionService $appVersionService
) {}
/**
* 버전 목록 + 등록 폼
*/
public function index(Request $request): View
{
$isSuperAdmin = auth()->user()?->is_super_admin ?? false;
$versions = $this->appVersionService->list(withTrashed: $isSuperAdmin);
return view('app-versions.index', compact('versions', 'isSuperAdmin'));
}
/**
* 새 버전 등록
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'version_code' => 'required|integer|min:1|unique:app_versions,version_code',
'version_name' => 'required|string|max:20',
'platform' => 'required|in:android,ios',
'release_notes' => 'nullable|string',
'force_update' => 'nullable|boolean',
'apk_file' => 'nullable|file|max:204800', // 200MB
]);
$this->appVersionService->store(
$request->only(['version_code', 'version_name', 'platform', 'release_notes', 'force_update']),
$request->file('apk_file')
);
return redirect()->route('app-versions.index')
->with('success', '새 버전이 등록되었습니다.');
}
/**
* 활성 토글
*/
public function toggleActive(int $id): RedirectResponse
{
$version = $this->appVersionService->toggleActive($id);
$status = $version->is_active ? '활성화' : '비활성화';
return redirect()->route('app-versions.index')
->with('success', "v{$version->version_name}{$status}되었습니다.");
}
/**
* 삭제
*/
public function destroy(int $id): RedirectResponse
{
$this->appVersionService->destroy($id);
return redirect()->route('app-versions.index')
->with('success', '버전이 삭제되었습니다.');
}
/**
* 복구 (슈퍼관리자 전용)
*/
public function restore(int $id): RedirectResponse
{
$version = $this->appVersionService->restore($id);
return redirect()->route('app-versions.index')
->with('success', "v{$version->version_name}이 복구되었습니다.");
}
/**
* 영구 삭제 (슈퍼관리자 전용)
*/
public function forceDestroy(int $id): RedirectResponse
{
$this->appVersionService->forceDestroy($id);
return redirect()->route('app-versions.index')
->with('success', '버전이 영구 삭제되었습니다.');
}
}