I have multiple models: User, Track, Tutorial, Chapter, Lesson, & SolvedLesson.
Below is what I've done to for counting each model.
$data = [
'userCount' => \App\User::count(),
'userRegisteredToday' => \App\User::whereCreatedAt(date('Y-m-d'))->count(),
'trackCount' => \App\Models\Track::count(),
'tutorialCount' => \App\Models\Tutorial::count(),
'chapterCount' => \App\Models\Chapter::count(),
'lessonCount' => \App\Models\Lesson::count(),
'solvedLessonCount' => \App\Models\SolvedLesson::count(),
];
Laravel provides relationships and eager loading to efficiently query. Is there any method to convert the above query into one single query for better performance?