Dashboard

Smart overview with agent-wise filters, finance, and recruitment performance.

@php $filters = [ 'agent_id' => request('agent_id'), 'company_id' => request('company_id'), 'destination_country' => request('destination_country'), 'from_date' => request('from_date'), 'to_date' => request('to_date'), ]; $agents = \App\Models\Agent::orderBy('name')->get(['id', 'name']); $companies = \App\Models\Company::orderBy('name')->get(['id', 'name']); $destinations = \App\Models\Candidate::query() ->whereNotNull('destination_country') ->where('destination_country', '!=', '') ->distinct() ->orderBy('destination_country') ->pluck('destination_country'); $applyCandidateFilters = function ($query) use ($filters) { return $query ->when($filters['agent_id'], fn ($q, $v) => $q->where('agent_id', $v)) ->when($filters['company_id'], fn ($q, $v) => $q->where('company_id', $v)) ->when($filters['destination_country'], fn ($q, $v) => $q->where('destination_country', $v)) ->when($filters['from_date'], fn ($q, $v) => $q->whereDate('created_at', '>=', $v)) ->when($filters['to_date'], fn ($q, $v) => $q->whereDate('created_at', '<=', $v)); }; $candidateBase = $applyCandidateFilters(\App\Models\Candidate::query()); $caseBase = \App\Models\RecruitmentCase::query()->whereHas('candidate', fn ($q) => $applyCandidateFilters($q)); $paymentBase = \App\Models\Payment::query()->whereHas('case.candidate', fn ($q) => $applyCandidateFilters($q)); $expenseBase = \App\Models\Expense::query()->whereHas('recruitmentCase.candidate', fn ($q) => $applyCandidateFilters($q)); $totalCandidates = (clone $candidateBase)->count(); $todayCandidates = (clone $candidateBase)->whereDate('created_at', now()->toDateString())->count(); $totalCases = (clone $caseBase)->count(); $closedCases = (clone $caseBase)->where('is_closed', true)->count(); $openCases = max($totalCases - $closedCases, 0); $totalPrice = (float) (clone $caseBase)->sum('total_price'); $totalPaid = (float) (clone $paymentBase)->sum('amount'); $totalDue = max($totalPrice - $totalPaid, 0); $totalExpense = (float) (clone $expenseBase)->sum('amount'); $profitAfterExpense = $totalPaid - $totalExpense; $avgPackage = $totalCases > 0 ? $totalPrice / $totalCases : 0; $collectionRate = $totalPrice > 0 ? round(($totalPaid / $totalPrice) * 100, 1) : 0; $expenseRate = $totalPaid > 0 ? round(($totalExpense / $totalPaid) * 100, 1) : 0; $activeAgents = (clone $candidateBase)->whereNotNull('agent_id')->distinct('agent_id')->count('agent_id'); $salaryPaid = 0.0; $salaryTotal = 0.0; if (\Illuminate\Support\Facades\Schema::hasTable('staff_salaries')) { $salaryTotal = (float) \Illuminate\Support\Facades\DB::table('staff_salaries')->sum('net_salary'); } if (\Illuminate\Support\Facades\Schema::hasTable('staff_salary_payments')) { $salaryPaid = (float) \Illuminate\Support\Facades\DB::table('staff_salary_payments')->sum('amount'); } elseif (\Illuminate\Support\Facades\Schema::hasTable('staff_salaries')) { $salaryPaid = (float) \Illuminate\Support\Facades\DB::table('staff_salaries')->sum('paid_amount'); } $salaryDue = max($salaryTotal - $salaryPaid, 0); $profitAfterSalary = $profitAfterExpense - $salaryPaid; $topAgents = \App\Models\Candidate::query() ->select('agent_id', \Illuminate\Support\Facades\DB::raw('COUNT(*) as candidates_count')) ->whereNotNull('agent_id') ->when($filters['company_id'], fn ($q, $v) => $q->where('company_id', $v)) ->when($filters['destination_country'], fn ($q, $v) => $q->where('destination_country', $v)) ->when($filters['from_date'], fn ($q, $v) => $q->whereDate('created_at', '>=', $v)) ->when($filters['to_date'], fn ($q, $v) => $q->whereDate('created_at', '<=', $v)) ->with('agent:id,name') ->groupBy('agent_id') ->orderByDesc('candidates_count') ->limit(5) ->get(); $recentCandidates = (clone $candidateBase) ->with(['agent:id,name', 'company:id,name']) ->latest() ->limit(5) ->get(); @endphp
Admin Analytics

Recruitment Performance Dashboard

Filter by agent, company, destination country, or date range to view exact business performance.

Collection Rate
{{ $collectionRate }}%
Active Agents
{{ $activeAgents }}

Smart Filters

Admin can find reports agent-wise and by more options.

Today This Month Reset
@foreach([ ['Total Candidates', number_format($totalCandidates), 'Filtered candidate count', '๐Ÿ‘ฅ'], ['Today Candidates', number_format($todayCandidates), now()->format('d M Y'), '๐Ÿ“…'], ['Total Package', number_format($totalPrice, 2), 'All filtered cases', '๐Ÿ’ผ'], ['Total Paid', number_format($totalPaid, 2), 'Received amount', '๐Ÿ’ณ'], ['Total Due', number_format($totalDue, 2), 'Package - paid', 'โš ๏ธ'], ['Total Expense', number_format($totalExpense, 2), 'Case expenses', '๐Ÿงพ'], ['Profit After Expense', number_format($profitAfterExpense, 2), 'Paid - expense', '๐Ÿ“ˆ'], ['Profit After Salary', number_format($profitAfterSalary, 2), 'After salary paid', '๐Ÿฆ'], ] as $stat)
{{ $stat[0] }}
{{ $stat[1] }}
{{ $stat[2] }}
{{ $stat[3] }}
@endforeach

Pipeline Summary

Quick health check for selected filter.

{{ $totalCases }} Cases
Open Cases
{{ $openCases }}
Closed Cases
{{ $closedCases }}
Average Package
{{ number_format($avgPackage, 2) }}
Payment Collection{{ $collectionRate }}%
Expense vs Paid{{ $expenseRate }}%

Salary Overview

Salary Paid
{{ number_format($salaryPaid, 2) }}
Due Salary
{{ number_format($salaryDue, 2) }}
Top Agents
Based on filtered candidates.
View Agents
@forelse($topAgents as $row)
{{ $row->agent?->name ?? 'No Agent' }}
{{ $row->candidates_count }} candidates
@empty
No agent data found for this filter.
@endforelse
Recent Candidates
Latest records from selected filter.
Open List
@forelse($recentCandidates as $candidate) @empty @endforelse
NameAgentCountryDate
{{ $candidate->full_name }}{{ $candidate->agent?->name ?? 'N/A' }}{{ $candidate->destination_country ?: 'N/A' }}{{ $candidate->created_at?->format('d M Y') }}
No candidates found.

Quick Actions

Common tasks for admin and manager.