<?php

//namespace App\Http\Controllers\Student;

use App\Http\Controllers\Controller;
use App\Models\Course;
use App\Models\Lesson;

class DashboardController extends Controller
{
    public function index()
    {
        // Replace this with your real enrolments when ready:
        $courses = Course::with('subject', 'level')->get();

        $otherCourses = Course::with('subject', 'level')
            ->whereNotIn('id', $courses->pluck('id'))
            ->get();

        $lastLesson = Lesson::with([
            'chapter',
            'lessonSection.module.course.subject',
            'lessonSection.module.course.level',
        ])->orderBy('id')->first();

        return view('student.dashboard', [
            'courses'       => $courses,
            'otherCourses'  => $otherCourses,
            'lastLesson'    => $lastLesson,
        ]);
    }
}