99 lines
No EOL
2.5 KiB
PHP
99 lines
No EOL
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Feed;
|
|
use App\Models\PlatformAccount;
|
|
use App\Models\PlatformChannel;
|
|
use App\Models\PlatformInstance;
|
|
use App\Services\SystemStatusService;
|
|
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()) {
|
|
$systemStatus = resolve(SystemStatusService::class)->getSystemStatus();
|
|
|
|
return view('pages.dashboard', compact('systemStatus'));
|
|
}
|
|
|
|
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();
|
|
}
|
|
} |