@php
$menuItems = config('demo1.menu.main');
$statsConfig = [
'Blog' => [
'model' => '\App\Modules\Blog\Models\Post',
'condition' => "where('status', 'published')",
'label' => 'Posts Activos',
'icon' => 'ki-document',
'color' => 'text-primary'
],
'FAQS' => [
'model' => '\App\Modules\Faqs\Models\Faq',
'condition' => '',
'label' => 'FAQs',
'icon' => 'ki-question',
'color' => 'text-success'
],
'Gallery' => [
'model' => '\App\Modules\Gallery\Models\Gallery',
'condition' => '',
'label' => 'Fotos en Galería',
'icon' => 'ki-gallery',
'color' => 'text-info'
],
'Artists' => [
'model' => '\App\Modules\TeamMembers\Models\TeamMember',
'condition' => '',
'label' => 'Artistas',
'icon' => 'ki-profile-circle',
'color' => 'text-warning'
],
'Services' => [
'model' => '\App\Modules\Services\Models\Service',
'condition' => '',
'label' => 'Servicios',
'icon' => 'ki-gear',
'color' => 'text-danger'
],
'Projects' => [
'model' => '\App\Modules\Projects\Models\Project',
'condition' => '',
'label' => 'Proyectos',
'icon' => 'ki-abstract-26',
'color' => 'text-dark'
],
'News' => [
'model' => '\App\Modules\CdBase\News\Models\News',
'condition' => '',
'label' => 'Noticias',
'icon' => 'ki-notification-bing',
'color' => 'text-primary'
],
'Users' => [
'model' => '\App\Models\User',
'condition' => '',
'label' => 'Usuarios',
'icon' => 'ki-profile-user',
'color' => 'text-success'
],
'Subscribers' => [
'model' => '\App\Models\NewsletterSubscriber',
'condition' => '',
'label' => 'Suscriptores',
'icon' => 'ki-notification-status',
'color' => 'text-info'
]
];
$activeModules = [];
foreach ($menuItems as $item) {
if (isset($item['title']) && !isset($item['content'])) {
$activeModules[] = $item['title'];
}
}
@endphp
@foreach($activeModules as $module)
@if(isset($statsConfig[$module]))
@php
$config = $statsConfig[$module];
$count = 0;
try {
if (class_exists($config['model'])) {
$modelClass = $config['model'];
if ($config['condition']) {
eval('$count = ' . $modelClass . '::' . $config['condition'] . '->count();');
} else {
$count = $modelClass::count();
}
}
} catch (Exception $e) {
$count = 0;
}
@endphp
@endif
@endforeach
Tokko Config