fedi-feed-router/app/Http/Controllers/OnboardingController.php

99 lines
2.5 KiB
PHP
Raw Normal View History

2025-07-06 11:22:53 +02:00
<?php
namespace App\Http\Controllers;
use App\Models\Feed;
use App\Models\PlatformAccount;
use App\Models\PlatformChannel;
use App\Models\PlatformInstance;
2025-07-10 11:06:17 +02:00
use App\Services\SystemStatusService;
2025-07-06 11:22:53 +02:00
use Illuminate\Http\Request;
use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
class OnboardingController extends Controller
{
public function index(): View|RedirectResponse
{
// Check if user needs onboarding
if (!$this->needsOnboarding()) {
2025-07-10 11:06:17 +02:00
$systemStatus = resolve(SystemStatusService::class)->getSystemStatus();
return view('pages.dashboard', compact('systemStatus'));
2025-07-06 11:22:53 +02:00
}
return view('onboarding.welcome');
}
public function platform(): View|RedirectResponse
{
if (!$this->needsOnboarding()) {
return redirect()->route('feeds.index');
}
return view('onboarding.platform');
}
public function feed(): View|RedirectResponse
{
if (!$this->needsOnboarding()) {
return redirect()->route('feeds.index');
}
if (!$this->hasPlatformAccount()) {
return redirect()->route('onboarding.platform');
}
return view('onboarding.feed');
}
public function channel(): View|RedirectResponse
{
if (!$this->needsOnboarding()) {
return redirect()->route('feeds.index');
}
if (!$this->hasPlatformAccount()) {
return redirect()->route('onboarding.platform');
}
if (!$this->hasFeed()) {
return redirect()->route('onboarding.feed');
}
return view('onboarding.channel');
}
public function complete(): View|RedirectResponse
{
if (!$this->needsOnboarding()) {
return redirect()->route('feeds.index');
}
if (!$this->hasPlatformAccount() || !$this->hasFeed() || !$this->hasChannel()) {
return redirect()->route('onboarding.index');
}
return view('onboarding.complete');
}
private function needsOnboarding(): bool
{
return !$this->hasPlatformAccount() || !$this->hasFeed() || !$this->hasChannel();
}
private function hasPlatformAccount(): bool
{
return PlatformAccount::where('is_active', true)->exists();
}
private function hasFeed(): bool
{
return Feed::where('is_active', true)->exists();
}
private function hasChannel(): bool
{
return PlatformChannel::where('is_active', true)->exists();
}
}