@extends('layouts.default') @push('title', get_phrase('My courses')) @push('meta')@endpush @push('css')@endpush @section('content')
@include('frontend.default.student.left_sidebar')

{{ get_phrase('My Courses') }}

@foreach ($my_courses as $course) @php $course_progress = progress_bar($course->course_id); @endphp
course-thumbnail
author-image
{{ $course->user_name }}

{{ ucfirst($course->title) }}

{{ get_phrase('Progress') }}

{{ $course_progress }}%

@if($course->expiry_date > 0 && $course->expiry_date < time())
{{ get_phrase('Expired') }}:
{{ date('d M Y, H:i A', $course->expiry_date) }}
@else @if($course->expiry_date == 0)
{{ get_phrase('Expiry period') }}:
{{ get_phrase('Lifetime Access') }}
@else
{{ get_phrase('Expiration On') }}:
{{ date('d M Y, H:i A', $course->expiry_date) }}
@endif @endif
@php $student_id = auth()->user()->id; $course_id = $course->course_id; $url = null; $watch_history = App\Models\Watch_history::where('course_id', $course_id) ->where('student_id', $student_id) ->first(); $lesson = App\Models\Lesson::where('course_id', $course_id) ->orderBy('section_id', 'asc') ->orderBy('sort', 'asc') ->first(); $total_lesson = App\Models\Lesson::where('course_id', $course_id) ->pluck('id') ->toArray(); if (!$watch_history && !$lesson) { $url = route('course.player', ['slug' => $course->slug]); } else { if ($watch_history) { $lesson_id = $watch_history->watching_lesson_id; } elseif ($lesson) { $lesson_id = $lesson->id; if ($watch_history && $watch_history->id) { // UPDATE (sebenarnya jarang masuk sini, tapi disamakan dgn referensi) $lessons = (array) json_decode($watch_history->completed_lesson); if (!in_array($lesson_id, $lessons)) { $lessons[] = $lesson_id; } App\Models\Watch_history::where('course_id', $course_id) ->where('student_id', $student_id) ->update([ 'completed_lesson' => json_encode($lessons), 'watching_lesson_id' => $lesson_id, 'completed_date' => count($total_lesson) == count($lessons) ? time() : null, ]); } else { App\Models\Watch_history::insert([ 'course_id' => $course_id, 'student_id' => $student_id, 'completed_lesson' => json_encode([$lesson_id]), 'watching_lesson_id' => $lesson_id, 'completed_date' => count($total_lesson) == 1 ? time() : null, ]); } } $url = route('course.player', [ 'slug' => $course->slug, 'id' => $lesson_id ]); } @endphp @if($course->expiry_date > 0 && $course->expiry_date < time()) {{ get_phrase('Renew') }} @else @if ($course_progress > 0 && $course_progress < 100.00) {{ get_phrase('Continue') }} @elseif ($course_progress == 100.00) {{ get_phrase('Watch again') }} @else {{ get_phrase('Start Now') }} @endif @endif
@endforeach @if ($my_courses->count() == 0)
@include('frontend.default.empty')
@endif
@if (count($my_courses) > 0)
@endif
@endsection @push('js') @endpush