@foreach($randomcources as $key =>$value)
<div class="col-md-4">
	<div class="item">
		<div class="card">
			@php
			$pcartprice =0;
			$pcartprice = ($value->discounted_price) ? $value->discounted_price : $value->price;
			
			@endphp
			@php
			$photos =array();
			if( !empty($value->product_image))
			{
			$photos = unserialize( $value->product_image);
			if(count($photos)>0)
			{
			$img_path=url('/logo/'.$photos['product_image']);
			@endphp
			<a href="{{url('/')}}/enrol/{{ $value->slug }}" class="packlink"><img class="card-img-top"  src="{{ $img_path }}"></a>
			@php
			}
			}
			@endphp
			<div class="card-body">
				<h3><a href="{{url('/')}}/enrol/{{ $value->slug }}" class="packlink">{{$value->package_name}}</a></h3>
				@foreach($educators as $educator)
				{{-- {{ $educator->id }} --}}
				
				@if($value->faculty_name==$educator->id )
				<p class="tutor">By <a href="{{url('/')}}/educator/{{ $educator->slug }}" class="educatorlink">{{$educator->coaching_classes}}</a></p>
				@endif
				@endforeach
				<h4 class="cross-t">
				<del>Rs.{{ $value->price }}</del>
				Rs.{{ $value->discounted_price }}
				</h4>
			</div>
		    <div class="over">
                <ul>
                    <li>
                        @if (Auth::check())
                        {!! Form::open(array('route' => 'cart.store', 'class' => 'form' ,'id' =>'createroomsform','files' => true)) !!}
                        {{ Form::hidden('product_id', $value->id) }}
                        {{ Form::hidden('user_id',Auth::user()->id ) }}
                        {{ Form::hidden('name', $value->package_name) }}
                        {{ Form::hidden('quantity', 1) }}
                        {{ Form::hidden('price', $pcartprice) }}
                        {!! Form::submit('',
                        array('class'=>'add-acte-down')) !!}
                        {!! Form::close() !!}
                        @else
                        <a title="Cart"  href=""  onClick="return false;" class="add-acte add-acte-cart" pid="{{$value->id}}"><i class="fas fa-cart-arrow-down"></i></a>
                        @endif
                    </li>
                    <li><a title="Call back" href="#" class="contact_user_detal" course_id="{{ $value->id }}"><i class="fas fa-phone-square"></i></a></li>
                        @if ($value->lectures_link!="")
                        <li> <a title="Video" href="javascript:void(0);" class="video"  product_id="{{course_video_link($value->id)}}"><i class="fab fa-youtube"></i></a></li>
                        @else
                         <li> <a href="#"  class="disable"><i class="fab fa-youtube"></i></a></li>
                        @endif
                    <li><a title="View" href="{{url('/')}}/enrol/{{ $value->slug }}"><i class="fas fa-eye"></i></a></li>
                    <li>
                        @if (Auth::check())
                        {!! Form::open(array('route' => 'wishlist.store', 'class' => 'form' ,'id' =>'createroomsform','files' => true)) !!}
                        {{ Form::hidden('product_id', $value->id) }}
                        {{ Form::hidden('user_id',Auth::user()->id ) }}
                        {{ Form::hidden('name', $value->package_name) }}
                        {{ Form::hidden('quantity', 1) }}
                        {{ Form::hidden('price', $pcartprice) }}
                        {!! Form::submit('',
                        array('class'=>'add-acte-login')) !!}
                        {!! Form::close() !!}
                        @else
                        <a title="Wishlist" href="" onClick="return false;" class="add-acte add-acte-wishlist" pid="{{$value->id}}"><i class="fas fa-heart"></i></a>
                        @endif
                    </li>
                </ul>
            </div>
        </div>
     </div>
</div>
@endforeach
<script src="{{ asset('user/js/jquery-2.2.0.min.js') }}"></script>

<script src="{{ asset('user/js/bootstrap.min.js') }}"></script>

<script src="{{ asset('user/js/jquery.slimNav_sk78.min.js') }}"></script>

<script src="{{ asset('user/js/owl.carousel.min.js') }}"></script>

<!-- <script src="{{ asset('user/js/masonry.pkgd.min.js') }}"></script> -->

<script src="{{ asset('user/js/login.js') }}"></script>

<!-- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> -->

<script type="text/javascript">

$(document).ready(function() {

  $('#navigation nav').slimNav_sk78();

  var owl = $('.online-courses');

  owl.owlCarousel({

  autoPlay: 3000, //Set AutoPlay to 3 seconds

  items:4,

  itemsMobile:[568,1],

  itemsTablet:[768,2],

  itemsTablet:[1024,3],

  navigation:true,

  loop:true,

  autoplay:true,

  autoplayTimeout:1000,

  autoplayHoverPause:true

  });



  var owl = $('.slider');

  owl.owlCarousel({

  autoPlay: 30000, //Set AutoPlay to 3 seconds

  items:1,

  itemsMobile:[568,1],

  itemsTablet:[768,3],

  itemsTablet:[1024,3],

  navigation:true,

  loop:true,

  autoplay:true,

  autoplayTimeout:10000,

  autoplayHoverPause:true

  });

});

</script>

<script>

$('#clickme').click(function() {

var $slider = $('.mydiv');

$slider.animate({

left: parseInt($slider.css('left'),10) == -$slider.outerWidth() ?

0 : -$slider.outerWidth()

});

});

$(function() {

$(".expand").on( "click", function() {

// $(this).next().slideToggle(200);

$expand = $(this).find(">:first-child");



if($expand.text() == "+") {

$expand.text("-");

} else {

$expand.text("+");

}

});

});

</script>
<script>
    $( function() {
        $( ".add-acte-cart" ).click(function(){
        console.log($(this).attr('pid'))
        var pid = $(this).attr('pid');
        $.ajax({
            type:'GET',
            url:'https://www.buyonlineclasses.com/setproductsession/'+pid,
            success:function(data){
                window.location.href = 'https://www.buyonlineclasses.com/login'
            }
            });
        });
        $( ".add-acte-wishlist" ).click(function(){
        console.log($(this).attr('pid'))
        var pid = $(this).attr('pid');
        $.ajax({
            type:'GET',
            url:'https://www.buyonlineclasses.com/setwishlistproduct/'+pid,
            success:function(data){
                window.location.href = 'https://www.buyonlineclasses.com/login'
            }
            });
        });
    });
</script>

<!-- <script type="text/javascript">

$( function() {

$( "#slider-range" ).slider({

range: true,

min: 0,

max: 500,

values: [ 75, 300 ],

slide: function( event, ui ) {

$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );

}

});

$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +

" - $" + $( "#slider-range" ).slider( "values", 1 ) );

} );

</script> -->

<!--Start of Tawk.to Script-->

<script type="text/javascript">

var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();

(function(){

var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];

s1.async=true;

s1.src='https://embed.tawk.to/5c24770e7a79fc1bddf25b19/default';

s1.charset='UTF-8';

s1.setAttribute('crossorigin','*');

s0.parentNode.insertBefore(s1,s0);

})();

</script>

<!--End of Tawk.to Script-->
<script type="text/javascript">

///Script for chane user in name and gender  in user profile page 
     
$(document).ready(function(){
    $('.details').on('click',function(){
      
        var id = $(this).attr('orderid');
      
        $.ajax({
            type: 'POST',
            dataType: 'html',
            url : 'https://www.buyonlineclasses.com/public/orders-address',
            data: { 'id':id,"_token": "{{ csrf_token() }}",
            },
            
            success: function(response1){
                console.clear();
                $('#my_modal_body').html(response1);
                $('#myModal-3').modal({show:true});
                 

            },
            error: function(response1){
                
            }
        });

  
    });

//Edit User Nmae and Gender Type

    $('#edit_user_name').on('click', function (e) {
        
      var name=$('#user_name').val();
      var gender=$('.gender:checked').val();
    
       $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url : 'https://www.buyonlineclasses.com/public/edit-profile-user-detail',
            data: { 'name':name,'gender':gender,"_token": "{{ csrf_token() }}",
            },
            
            success: function(response1){
                console.clear();

                if(response1['status']=='success'){
 
                 // location.reload();
               }
            },
            error: function(response1){
                
            }
        });

    });

    //Script for change user email

    $('#edit_user_email_button').on('click', function (e) {
        

      var user_email=$('#user_email').val();
    
       $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url : 'https://www.buyonlineclasses.com/public/edit-profile-user-email',
            data: { 'user_email':user_email,"_token": "{{ csrf_token() }}",
            },
            
            success: function(response1){
                console.clear();

                if(response1['status']=='success'){
 
                  location.reload();
               }
            },
            error: function(response1){
                
            }
        });

    });


    //script for change user mobile
    $('#edit_user_mobile_button').on('click', function (e) {
        

       var user_mobile=$('#user_mobile').val();
      
       $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url : 'https://www.buyonlineclasses.com/public/edit-profile-user-mobile',
            data: { 'user_mobile':user_mobile,"_token": "{{ csrf_token() }}",
            },
            
            success: function(response1){
                console.clear();

                if(response1['status']=='success'){
 
                  location.reload();
               }
            },
            error: function(response1){
                
            }
        });

    });


    //Script for edit shipping address

    $('#edit_user_billing__address_buttonnhg').on('click', function (e) {

        var first_name_billing=$('#first_name_billing').val();
        var last_name_billing=$('#last_name_billing').val();
        var billing_email=$('#billing_email').val();
        var postcode_shipping=$('#postcode_shipping').val();
        var addreess_shipping=$('#addreess_shipping').val();
        var city_shipping=$('#city_shipping').val();
        var state_shipping=$('#state_shipping').val();
        

      var user_email=$('#user_email').val();
    
       $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url : 'https://www.buyonlineclasses.com/public/edit-billing-address',
            data: { 'first_name_billing':first_name_billing,'last_name_billing':last_name_billing,'billing_email':billing_email,"_token": "{{ csrf_token() }}",
            },
            
            success: function(response1){
                console.clear();

                if(response1['status']=='success'){
 
                  location.reload();
               }
            },
            error: function(response1){
                
            }
        });

    });

});





//Show video

$('.video').on('click', function (e) {

        var video = $(this).attr('product_id');
        $('#play_video').html('<iframe src="https://www.youtube.com/embed/'+video+'" width="100%" height="250px"></iframe>');
        $(".vidd").attr("href",'https://www.facebook.com/dialog/share?app_id=87741124305&href=https%3A%2F%2Fwww.youtube.com%2Fattribution_link%3Fa%3DAHY3MWCLjKk%26u%3D%252Fwatch%253Fv%253D'+video+'%2526feature%253Dplayer_embedded&display=popup&redirect_uri=https%3A%2F%2Fwww.youtube.com%2Ffacebook_redirect');
    $("#whatsappa").attr("href", 'whatsapp://send?text=https://www.youtube.com/embed/'+video);
    setTimeout(function(){ $('#show_video').modal({show:true}); }, 200);
    return false;
  });
  
   //on close remove video
    $('#show_video').on('hidden.bs.modal', function () {
       $('#show_video #play_video').empty();
    });

 //Show Product Contact Form

 $('.contact_user_detal').on('click', function (e) {

        var product_id=$(this).attr('course_id');
        $("#pro_id").val(product_id);
        $('#show_contact').modal({show:true});

    });

//called when key is pressed in textbox
     $("#u_c_phone").keypress(function (e) {
          //if the letter is not digit then display error and don't type anything
          if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
          return false;
         }
      });

 //script for insert Product Contact user contact information
     var createform = $('#createform');
     createform.submit(function(e) {
     e.preventDefault();

      var user_fullname=$('#u_c_name').val();
      var user_email=$('#u_c_email').val();
      var user_phone=$('#u_c_phone').val();
      var user_message=$('#u_c_message').val();
      var product_id=$("#pro_id").val();



      $(".error1").remove();

      if (user_fullname.length < 1) {
        $('#u_c_name').after('<span class="error1">Fullname field is required</span>');
      }
       
       if (user_email.length < 1) {
          
        $('#u_c_email').after('<span class="error1">Email field is required</span>');
      } else {
        var regEx = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
        var validEmail = regEx.test(user_email);
        if (!validEmail) {

          $('#u_c_email').after('<span class="error1">Email must be an email address</span>');
        }
      } 
      if (user_phone.length < 1) {
        $('#u_c_phone').after('<span class="error1">Phone field is required</span>');
      }

     

      if (!$(".error1").length) {
      $.ajax({
        type: 'POST',
        dataType: 'JSON',
        url : 'https://www.buyonlineclasses.com/save-information',
        data: {'user_fullname':user_fullname,'user_email':user_email,'user_phone':user_phone,'user_message':user_message,'product_id':product_id,"_token": "{{ csrf_token() }}",
        },
        
        success: function(response1){
            console.clear();
            if(response1.suc){
               $('#show_contact').modal('hide');
                 
             }
           
        },
        error: function(response1){
            
        }

    });
    
   }

  });
</script>