@extends('Admin.master_page')



@section('title') <h5 class="m-0 font-weight-bold text-primary" style="float: left;">Sub Category List</h5> 

<a href="{{ route('SubCategory.create') }}" style="float: right;"><i class="fas fa-plus-circle"></i></a>
@endsection

@section('content')

@if(Session::has('success_message'))
<div class="alert alert-success">{{ Session::get('success_message') }}</div>
@endif

<div class="table-responsive"> 

 	<br>
 	<table class="table">
 	 <thead>
 	  <tr>
 	   <th>#</th>
 	    <th>Main Category</th>
 	    <th>Sub Category</th>
 	    <th>Action</th>
 	       </tr>
 	        </thead> 
 	        <tbody>
 	        @foreach($subs as $sub)		
 	         <tr>
 	          <td>{{ $sub->id }}</td>
 	           <td>{{ $sub->status_category->name }}</td>
 	           <td>{{ $sub->name }}</td>
 	            
 	             <td>
			
				  <form action="{{route('SubCategory.destroy' , $sub->id)}}" method="post" id="form-{{$sub->id}}">
                        {{csrf_field()}}
                        {{method_field("DELETE")}}
                    </form>

                    <a href="{{ route('SubCategory.edit' , $sub->id) }}" ><i class="fas fa-edit"></i></a>

                    &nbsp;
                                   <a href=""
                       onclick="if(confirm('Are you sure to delete?')) {
                               event.preventDefault();
                               document.getElementById('form-{{$sub->id}}').submit();
                               }else{ event.preventDefault(); }"
                       ><i class="fas fa-trash-alt"></i></a>
   
 	             </td> 
 	            
 	         </tr>
 	         @endforeach


 	                 </tbody> 
 	             </table> 

 	             

 	         </div> 



@endsection