@php // ── Check if we're on a tenant subdomain ── $tenant = request()->get('current_tenant'); $isTenantContext = $tenant !== null; // ── Get settings based on context ── if ($isTenantContext) { $tenantSettings = \App\Models\TenantSetting::getAllForTenant($tenant->id); $siteLogo = $tenantSettings['logo_dark'] ?? null; $siteName = $tenantSettings['company_name'] ?? $tenant->name ?? 'Admin Portal'; $primaryColor = $tenantSettings['primary_color'] ?? '#c9a96e'; $tagline = $tenantSettings['tagline'] ?? 'Sign in to your account'; } else { $platformSettings = \App\Models\Setting::getAllAsArray(); $siteLogo = $platformSettings['app_logo_dark'] ?? null; $siteName = $platformSettings['app_name'] ?? 'Admin Portal'; $primaryColor = $platformSettings['primary_color'] ?? '#c9a96e'; $tagline = 'Sign in to your account'; } // ── Logo URL helper ── $logoUrl = null; if ($siteLogo) { if ($isTenantContext) { $logoUrl = asset('storage/tenants/' . $tenant->id . '/' . $siteLogo); } else { $logoUrl = asset('storage/settings/' . $siteLogo); } } // ── Page title ── $pageTitle = $isTenantContext ? $siteName . ' - Login' : 'Admin Login'; // ── Registration URL ── $registerUrl = $isTenantContext ? url('/' . $tenant->slug . '/admin/register') : url('/admin/register-form'); // ── Login URL ── $loginUrl = $isTenantContext ? url('/' . $tenant->slug . '/admin/login') : url('/admin/login'); // ── Forgot password URL ── $forgotUrl = $isTenantContext ? '#' : (Route::has('password.request') ? route('password.request') : '#'); // ── Check if already logged in ── $currentAdmin = auth()->guard('admin')->user(); $isLoggedIn = $currentAdmin !== null; $isPlatformOwner = $isLoggedIn && $currentAdmin->role === 'platform_owner' && $currentAdmin->tenant_id === null; $isTenantAdmin = $isLoggedIn && $currentAdmin->tenant_id !== null; // ── If logged in as tenant admin and trying to access their own tenant ── $isSameTenant = $isTenantAdmin && $tenant && $currentAdmin->tenant_id == $tenant->id; // ── If logged in as tenant admin and trying to access different tenant ── $isDifferentTenant = $isTenantAdmin && $tenant && $currentAdmin->tenant_id != $tenant->id; @endphp {{ $pageTitle }} {{-- FontAwesome & Google Fonts --}}
{{-- Header --}}

{{ $siteName }}

{{ $tagline }}

@if($isTenantContext)
{{ $tenant->name }}
@endif
{{-- Body --}}
{{-- ── ALREADY LOGGED IN WARNINGS ─────────────────────────── --}} {{-- Platform Owner logged in --}} @if($isPlatformOwner)
You are already logged in as Platform Owner!

To login as a tenant admin, please logout from Platform Owner first.

@csrf
@endif {{-- Tenant Admin logged in - same tenant --}} @if($isSameTenant)
You are already logged in as {{ $currentAdmin->name }}

You are already logged in to {{ $tenant->name }}. Go to Dashboard →

@endif {{-- Tenant Admin logged in - different tenant --}} @if($isDifferentTenant)
You are already logged in as {{ $currentAdmin->name }}

You are currently logged in to a different tenant. To login to {{ $tenant->name }}, please logout first.

@csrf
@endif {{-- Session messages --}} @if(session('message'))
{{ session('message') }}
@endif @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Validation errors --}} @if($errors->any())
    @foreach($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif {{-- Only show login form if not already logged in or if not same tenant --}} @if(!$isPlatformOwner && !$isSameTenant)
@csrf {{-- Email --}}
@error('email')
{{ $message }}
@enderror
{{-- Password --}}
@error('password')
{{ $message }}
@enderror
{{-- Remember me + Forgot password --}}
@if($forgotUrl !== '#') Forgot password? @endif
@endif
{{-- Footer --}}