addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
slug;
$typeName = ucfirst(str_replace('-', ' ', $typeSlug));
$count = in_array($typeSlug, $staticSlugs)
? ($staticCounts[$typeSlug] ?? 0)
: $customListings->where('type', $typeSlug)->count();
?>
popLoop(); $loop = $__env->getLastLoop(); ?>
$beauty,
'hotel' => $hotel,
'restaurant' => $restaurant,
'real-estate' => $realEstate,
'car' => $car,
];
$staticSlugs = array_keys($staticCounts);
$allTypes = \App\Models\CustomType::where('status', 1)->orderBy('sorting', 'asc')->get();
$customListings = \App\Models\CustomListings::where('visibility', 'visible')->get();
$totalListing = array_sum($staticCounts) + $customListings->count();
$labels = [];
$percentages = [];
$colors = [];
// Predefined colors for first 5 static types
$presetColors = ["#FF736A", "#124797", "#EF255C", "#44A1ED", "#0F0B0B"];
$dynamicColorPool = ['#7F27FF', '#35A29F', '#F86F03', '#A34343', '#4C4B16', '#7286D3', '#43766C', '#FD8D14', '#B3005E', '#A0C49D'];
$colorIndex = 0;
foreach ($allTypes as $index => $type) {
$slug = $type->slug;
$name = ucfirst(str_replace('-', ' ', $slug));
$count = in_array($slug, $staticSlugs)
? ($staticCounts[$slug] ?? 0)
: $customListings->where('type', $slug)->count();
$percentage = $totalListing > 0 ? round(($count / $totalListing) * 100, 2) : 0;
$labels[] = $name;
$percentages[] = $percentage;
// Use static color if available, otherwise pick from dynamic pool
$colors[] = $presetColors[$index] ?? $dynamicColorPool[$colorIndex++ % count($dynamicColorPool)];
}
?>
selectRaw("MONTH(created_at) as month, SUM(paid_amount) as total_earning")
->whereYear('created_at', $currentYear)
->groupBy(DB::raw("MONTH(created_at)"))
->orderBy(DB::raw("MONTH(created_at)"))
->get();
$monthlyData = [];
for ($i = 1; $i <= 12; $i++) {
$earningsForMonth = $monthlyEarnings->firstWhere('month', $i);
$monthlyData[$i] = $earningsForMonth ? $earningsForMonth->total_earning : 0;
}
?>