@extends('layouts.admin') @section('title','الإيرادات') @section('breadcrumb')الإيرادات@endsection @section('content')

الإيرادات

@php $plans = \App\Models\Plan::withCount('tenants')->where('is_active',true)->get(); $activeTenants = \App\Models\Tenant::with('plan')->where('subscription_status','active')->get(); $monthlyRevenue = $activeTenants->sum(fn($t) => $t->plan?->price_monthly ?? 0); $yearlyRevenue = $monthlyRevenue * 12; $trialCount = \App\Models\Tenant::where('subscription_status','trial')->count(); @endphp {{-- KPIs --}}

الإيراد الشهري (MRR)

{{ number_format($monthlyRevenue) }}

SAR

الإيراد السنوي المتوقع

{{ number_format($yearlyRevenue) }}

SAR

عملاء نشطون

{{ $activeTenants->count() }}

شركة

في فترة تجريبية

{{ $trialCount }}

شركة

{{-- Revenue by Plan --}}

الإيرادات حسب الخطة

@foreach($plans as $plan) @php $planRevenue = $plan->tenants_count * $plan->price_monthly @endphp
{{ $plan->name_ar }}
{{ $plan->tenants_count }} شركة × {{ number_format($plan->price_monthly) }} SAR {{ number_format($planRevenue) }} SAR/شهر
@endforeach
{{-- Active Tenants Table --}}

الشركات النشطة

@forelse($activeTenants as $t) @empty @endforelse
الشركة الخطة الإيراد الشهري انتهاء الاشتراك

{{ $t->name }}

{{ $t->email }}

{{ $t->plan?->name_ar ?? '—' }} {{ number_format($t->plan?->price_monthly ?? 0) }} SAR {{ $t->subscription_ends_at?->format('d/m/Y') ?? '—' }}
لا توجد شركات نشطة
@endsection