- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
38 lines
1,022 B
PHP
38 lines
1,022 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Themes;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Themes\ActivateThemeRequest;
|
|
use App\Services\ThemeService;
|
|
use Exception;
|
|
|
|
/**
|
|
* Controller for activating a theme.
|
|
*/
|
|
class ThemeActivateController extends Controller
|
|
{
|
|
/**
|
|
* Handle the activation request.
|
|
*
|
|
* @param \App\Http\Requests\Admin\Themes\ActivateThemeRequest $request
|
|
* @param \App\Services\ThemeService $themeService
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function __invoke(ActivateThemeRequest $request, ThemeService $themeService)
|
|
{
|
|
$themeSlug = $request->input('theme');
|
|
|
|
try {
|
|
$themeService->activate($themeSlug);
|
|
|
|
return response()->json([
|
|
'message' => 'Theme activated successfully.',
|
|
'active_theme' => $themeSlug,
|
|
]);
|
|
} catch (Exception $e) {
|
|
return response()->json(['message' => $e->getMessage()], 404);
|
|
}
|
|
}
|
|
}
|