startOfMonth(); $newThisMonth = Person::where('created_at', '>=', $currentMonthStart)->count(); // Recent additions (last 30 days) $thirtyDaysAgo = Carbon::now()->subDays(30); $recentAdditions = Person::where('created_at', '>=', $thirtyDaysAgo)->count(); // Pending reviews - example: people with missing information $pendingReviews = Person::whereNull('date_of_birth') ->orWhereNull('place_of_birth') ->orWhereNull('occupation') ->count(); // Incomplete records - persons missing multiple key fields $incompleteRecords = Person::where(function($query) { $query->whereNull('date_of_birth') ->orWhereNull('place_of_birth'); }) ->where(function($query) { $query->whereNull('occupation') ->orWhereNull('reference') ->orWhereNull('id_card_no'); }) ->count(); return response()->json([ 'success' => true, 'data' => [ 'total_migrants' => $totalMigrants, 'new_this_month' => $newThisMonth, 'recent_additions' => $recentAdditions, 'pending_reviews' => $pendingReviews, 'incomplete_records' => $incompleteRecords ] ]); } }