app/Http/Controllers/Instructor/Courses/CourseController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $activeCourses = Course::where('status', 'PUBLISHED')
            ->where('teacher_id', Auth::user()->id)
            ->count();
        $pendingCourses = Course::where('status', 'PENDING')
            ->where('teacher_id', Auth::user()->id)
            ->count();
        $draftCourses = Course::where('status', 'DRAFT')
            ->where('teacher_id', Auth::user()->id)
            ->count();
        $freeCourses = Course::where('free_course', 1)
            ->where('teacher_id', Auth::user()->id)
            ->count();
        $paidCourses = Course::where('free_course', 0)
            ->where('teacher_id', Auth::user()->id)
            ->count();
        $allCourses = Course::where('teacher_id', Auth::user()->id)
            ->with(['category', 'user'])
            ->orderBy('created_at', 'desc')
            ->paginate(7, ['id', 'title', 'slug', 'teacher_id', 'category_id', 'status']);
        $courses = Course::where('teacher_id', Auth::user()->id)
            ->count();
        return response()
            ->json([
                'activeCourses' => $activeCourses,
                'pendingCourses' => $pendingCourses,
                'draftCourses' => $draftCourses,
                'freeCourses' => $freeCourses,
                'paidCourses' => $paidCourses,
                'allCourses' => $allCourses,
                'courses' => $courses
            ]);
    }
public function index ( ) { $ activeCourses = Course :: where ( 'status' , 'PUBLISHED' ) -> where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; $ pendingCourses = Course :: where ( 'status' , 'PENDING' ) -> where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; $ draftCourses = Course :: where ( 'status' , 'DRAFT' ) -> where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; $ freeCourses = Course :: where ( 'free_course' , 1 ) -> where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; $ paidCourses = Course :: where ( 'free_course' , 0 ) -> where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; $ allCourses = Course :: where ( 'teacher_id' , Auth :: user ( ) -> id ) -> with ( [ 'category' , 'user' ] ) -> orderBy ( 'created_at' , 'desc' ) -> paginate ( 7 , [ 'id' , 'title' , 'slug' , 'teacher_id' , 'category_id' , 'status' ] ) ; $ courses = Course :: where ( 'teacher_id' , Auth :: user ( ) -> id ) -> count ( ) ; return response ( ) -> json ( [ 'activeCourses' => $ activeCourses , 'pendingCourses' => $ pendingCourses , 'draftCourses' => $ draftCourses , 'freeCourses' => $ freeCourses , 'paidCourses' => $ paidCourses , 'allCourses' => $ allCourses , 'courses' => $ courses ] ) ; }
Display a listing of the resource.
Display a listing of the resource .