@php
$mytime = Carbon\Carbon::now();
@endphp
@foreach($coursechapter->courseclass->sortBy('position') as $class)
@if(Auth::user()->role == "user" && $course->drip_enable == 1 && $class->drip_type != NULL)
@if($class->drip_type == 'date' && $class->drip_date != NULL)
@if($today >= $class->drip_date)
@include('include.course_class')
@endif
@elseif($class->drip_type == 'days' && $class->drip_days != NULL)
@php
$order = App\Order::where('status', '1')->where('user_id', Auth::User()->id)->where('course_id', $course->id)->first();
$days = $class->drip_days;
$orderDate = optional($order)['created_at'];
$bundle = App\Order::where('user_id', Auth::User()->id)->where('bundle_id', '!=', NULL)->get();
$course_id = array();
foreach($bundle as $b)
{
$bundle = App\BundleCourse::where('id', $b->bundle_id)->first();
array_push($course_id, $bundle->course_id);
}
$course_id = array_values(array_filter($course_id));
$course_id = array_flatten($course_id);
if($orderDate != NULL){
$startDate = date("Y-m-d", strtotime("$orderDate +$days days"));
}
elseif(isset($course_id) && in_array($course->id, $course_id)){
$startDate = date("Y-m-d", strtotime("$bundle->created_at +$days days"));
}
@endphp
@if($today >= $startDate)
@include('include.course_class')
@endif
@endif
@else
@include('include.course_class')
@endif
@endforeach