@extends('admin.app')

@section('page_title','All Courses') 

@section('page_location')
<ol class="breadcrumb">
      <li><a href="javascript:void('0');"><i class="fa fa-dashboard"></i> Home</a></li>
      <li><a href="javascript:void('0');">All  Courses</a></li>
      <li class="active">all</li>
</ol>
@endsection

@section('main-content')
<div class="row">
<div class="col-xs-12">
<div class="box">
  <div class="box-header">
    {{-- <h3 class="box-title" style="float: left;">View All Content Type</h3> --}}
    {{-- {{ route('user.index') }} --}}
    <!-- /.box-header -->
    @php $i=1; @endphp
    @if(isset($courses))
    <div class="box-body table-responsive no-padding">
      <table class="table table-hover" id="example">
        <thead>
          <th>Id</th>
          <th>Package Name</th>
          <th>Slug</th>
          <th>Product Image</th>
          <th>Popular</th>
          <th>Shipment Required</th>
          <th>syllabus</th>
          <th>material by</th>
          <th>Price</th>
          <th>Discount(%)</th>
          <th>Discount Price</th>
          <th>Applicable</th>
          <th>Faculty</th>
          <th>Status</th>
          <th id="action_th">Action</th> 
        </thead>
        <tbody>
         
            @foreach($courses as $value)
          <tr>
          <td style="">{{ $i++ }}</td>
        
          <td style="">
              {{ $value->package_name }}
          </td>   
            <td style="">
              {{ $value->slug }}
          </td>   
            <td>
           @php 
            $photos =array();
            if( !empty($value->product_image))
            {
              $photos = unserialize( $value->product_image);
              if(count($photos)>0)
              {
                
                $img_path=url('/logo/'.$photos['product_image']); 
                echo '<img src="'.$img_path.'" width="100px">';
              }
              
            }                             
           @endphp
         </td> 
          <td style="">
              {{ $value->popular }}
          </td>   
           <td style="">
              {{ $value->shipment_required }}
          </td>   
           <td style="">
              {{ $value->syllabus }}
          </td>  
           <td style="">
              {{ $value->material_by }}
          </td>   
           <td style="">
              {{ $value->price }}
          </td>    
          <td style="">
                @foreach($educators as $educator)
                {{-- {{ $educator->id }} --}}
                @php
                if($value->faculty_name==$educator->id ) echo $educator->discount;
                @endphp
                   
                 @endforeach
              {{-- {{ $value->faculty_name }} --}}
          </td> 
           <td style="">
              {{ $value->discounted_price }}
          </td>    
           <td style="">
              {{ $value->applicable_for_attempt }}
          </td>  
            <td style="">
                @foreach($educators as $educator)
                {{-- {{ $educator->id }} --}}
                @php
                if($value->faculty_name==$educator->id ) echo $educator->coaching_classes;
                @endphp
                   
                 @endforeach
              {{-- {{ $value->faculty_name }} --}}
          </td> 
        
          <td>
                @if ($value->status== 1)
                <span class="label label-success">Active</span>
                @elseif($value->status== 0)
                <span class="label label-danger">Inactive</span>
                @endif
          </td>
          <td class="action_box">
           @if(checkPermission(GetRoleID(Auth::user()->id),'edit-courses'))                                     
            <a href="<?php echo url('/admin/course/'.$value->id.'/edit');?>" title="Edit" style="color: black;">
            <span class="pull-right-container">
              <i class="fa fa-edit"></i>
            </span>
            </a>
           @endif
           @if(checkPermission(GetRoleID(Auth::user()->id),'delete-courses'))
           <form action="{{ route('course.destroy', $value->id ) }}" method="POST">
              {{ method_field('DELETE') }}
              {{ csrf_field() }}
              <button><i class="fa fa-trash"></i> </button>
           </form>                                          
           @endif   
          </td>
        </tr>
        @endforeach
      </tbody>
    </table>
    @endif
  </div>
</div>
<!-- /.box -->
</div>
</div>
@endsection

