Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SettingsController | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| update | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers; |
| 4 | |
| 5 | use App\Models\Setting; |
| 6 | use Illuminate\Contracts\View\View; |
| 7 | use Illuminate\Http\RedirectResponse; |
| 8 | use Illuminate\Http\Request; |
| 9 | |
| 10 | class SettingsController extends Controller |
| 11 | { |
| 12 | public function index(): View |
| 13 | { |
| 14 | $articleProcessingEnabled = Setting::isArticleProcessingEnabled(); |
| 15 | $publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled(); |
| 16 | |
| 17 | return view('pages.settings.index', compact('articleProcessingEnabled', 'publishingApprovalsEnabled')); |
| 18 | } |
| 19 | |
| 20 | public function update(Request $request): RedirectResponse |
| 21 | { |
| 22 | $request->validate([ |
| 23 | 'article_processing_enabled' => 'boolean', |
| 24 | 'enable_publishing_approvals' => 'boolean', |
| 25 | ]); |
| 26 | |
| 27 | Setting::setArticleProcessingEnabled($request->boolean('article_processing_enabled')); |
| 28 | Setting::setPublishingApprovalsEnabled($request->boolean('enable_publishing_approvals')); |
| 29 | |
| 30 | // If redirected from onboarding, go to dashboard |
| 31 | if ($request->get('from') === 'onboarding') { |
| 32 | return redirect()->route('onboarding.index') |
| 33 | ->with('success', 'System activated successfully! Welcome to Lemmy Poster.'); |
| 34 | } |
| 35 | |
| 36 | return redirect()->route('settings.index') |
| 37 | ->with('success', 'Settings updated successfully.'); |
| 38 | } |
| 39 | } |