@if(true || $profile->purchases->count() > 0)
@foreach( $courses->sortBy('course_id') as $purchase )
@php
$course = $purchase;
$active = null;
if($purchase instanceof \App\Purchases){
$course = $purchase->course;
//check if there is a current certificate for the user
$active = $profile->purchases()->whereHas('course',function($q)use($course){
$q->where('course_id',$course->id);
})->where(function($q){
$q->whereNotNull('user_purchases.certificate_id')->where('expiry_date','>',date('Y-m-d'));
})->where('user_purchases.id','!=',$purchase->id)
->leftJoin('assigned_certificates as ac','user_purchases.certificate_id','=','ac.assigned_id')
->orderBy('user_purchases.id','desc')
->first();
}
@endphp
@if($course->timer == 1)
{{strtoupper(__('chapters'))}} |
{{strtoupper(__('progress'))}} |
@foreach ($course->chapters as $chapter)
Chapter {{ $i++ }} – {{ $chapter->getAttributes()['name'] }} |
@foreach ($courses_progress as $progress)
@if($progress->chapter_id == $chapter->getAttributes()['chapter_id'])
{{ $progress->progress }} %
@endif
@endforeach
|
@endforeach
@else
@php
$course_token = null;
$all_chapters = $course->chapters->pluck('chapter_id')->toArray();
$chapter_id = null;
if($purchase instanceof \App\Purchases){
$chapter_id = $courses_progress->whereIn('chapter_id',$all_chapters)->where('user_purchase_id',$purchase->id)->where('progress',100)->max('chapter_id');
$course_token = $purchase->course_token;
}else{
$chapter_id = $courses_progress->whereIn('chapter_id',$all_chapters)->where('progress',100)->max('chapter_id');
}
$max_chapter = $course->chapters->max('chapter_id');
$nex_chapter = null;
if($chapter_id < $max_chapter){
$pos = array_search($chapter_id,$all_chapters);
if($pos!==false){
$pos++;
$nex_chapter =$all_chapters[$pos];
}
}
@endphp
{{--If they have no chapters then they show the introduction--}}
{{ str_replace(['tabc'],['TABC'],preg_replace('/course/i','',$course->title)) }} Course
{!!$course->tag_line!!}
@if(false && $active)
{{ucfirst(__('you have an active certificate that expires on'))}} {{ date('F d, Y',strtotime($active->expiry_date)) }}
@endif
@if(empty($chapter_id))
{{ucwords(__('begin course'))}}
{{--If they have finished all the chapters the show the exam--}}
@elseif($chapter_id == $max_chapter)
{{ucwords(__('take exam'))}}
@elseif($chapter_id == 'cleared')
@else
Current Chapter: {{ $course->chapters->where('chapter_id',$nex_chapter)->first()['name'] }}
{{ucwords(__('continue cours'))}}e
@endif
@endif
@endforeach
{{--Show any course that the user doesnt have.--}}
@if(!empty($available_courses))
@foreach($available_courses->sortBy('course_id') as $course)
@php
//check if there are any certs that have not expired yet for the
$active = $profile->purchases()->whereHas('course',function($q)use($course){
$q->where('course_id',$course->id);
})->where(function($q){
$q->whereNotNull('user_purchases.certificate_id')->where('expiry_date','>',date('Y-m-d'));
})->leftJoin('assigned_certificates as ac','user_purchases.certificate_id','=','ac.assigned_id')
->orderBy('user_purchases.id','desc')
->first();
@endphp
{{ preg_replace('/course/i','',$course->title) }} Course
{!! $course->tag_line !!}
@if($active)
{{ucfirst(__('you have an active certificate that expires on'))}} {{ date('F d, Y',strtotime($active->expiry_date)) }}
@endif
{{ucwords(__('signup for this course'))}}.
@endforeach()
@endif
{{--Show any course that the user doesnt have.--}}
@else