2025-07-10 11:01:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Setting;
|
2025-07-10 11:24:48 +02:00
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
2025-07-10 11:01:01 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class SettingsController extends Controller
|
|
|
|
|
{
|
2025-07-10 11:24:48 +02:00
|
|
|
public function index(): View
|
2025-07-10 11:01:01 +02:00
|
|
|
{
|
|
|
|
|
$articleProcessingEnabled = Setting::isArticleProcessingEnabled();
|
2025-07-10 14:57:10 +02:00
|
|
|
$publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled();
|
2025-07-10 11:01:01 +02:00
|
|
|
|
2025-07-10 14:57:10 +02:00
|
|
|
return view('pages.settings.index', compact('articleProcessingEnabled', 'publishingApprovalsEnabled'));
|
2025-07-10 11:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 11:24:48 +02:00
|
|
|
public function update(Request $request): RedirectResponse
|
2025-07-10 11:01:01 +02:00
|
|
|
{
|
|
|
|
|
$request->validate([
|
|
|
|
|
'article_processing_enabled' => 'boolean',
|
2025-07-10 14:57:10 +02:00
|
|
|
'enable_publishing_approvals' => 'boolean',
|
2025-07-10 11:01:01 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Setting::setArticleProcessingEnabled($request->boolean('article_processing_enabled'));
|
2025-07-10 14:57:10 +02:00
|
|
|
Setting::setPublishingApprovalsEnabled($request->boolean('enable_publishing_approvals'));
|
2025-07-10 11:01:01 +02:00
|
|
|
|
2025-07-10 11:32:07 +02:00
|
|
|
// If redirected from onboarding, go to dashboard
|
|
|
|
|
if ($request->get('from') === 'onboarding') {
|
|
|
|
|
return redirect()->route('onboarding.index')
|
|
|
|
|
->with('success', 'System activated successfully! Welcome to Lemmy Poster.');
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 11:01:01 +02:00
|
|
|
return redirect()->route('settings.index')
|
|
|
|
|
->with('success', 'Settings updated successfully.');
|
|
|
|
|
}
|
|
|
|
|
}
|