@extends('Admin.master_page')

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

<a href="{{ route('DomainSale.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="col-lg-5">
	<form action="" method="get">
		<div class="input-group">
			<input type="text" name="domain" class="form-control" placeholder="Enter Domain Name">
		</div>
	</form>
</div>


<div class="table-responsive"> 

 	<br>
 	<table class="table">
 	 <thead>
 	  <tr>
 	    <th>Domain Name</th>
 	    <th>Price</th>
 	     <th>Old</th>
 	     <th>Status</th>
 	      <th>Details</th>
 	      <th>Action</th>
 	       </tr>
 	        </thead> 
 	        <tbody>
 	        @foreach($domains as $domain)		
 	         <tr>
 	            <td >{{ $domain->name }}</td>
 	            <td >{{ $domain->price }}</td>
 	             <td >{{ Carbon\Carbon::parse($domain->registrar_date)->age }}</td> 
                  <td>
                      @if($domain->status == 1)
                        Available
                      @else
                        SOLD
                      @endif
                  </td>
 	             <td ><a href="{{ route('DomainSale.show' , $domain->id) }}"><i class="fas fa-list-ul"></i></a></td> 
 	            
  	             <td>
			
				  <form action="{{route('DomainSale.destroy' , $domain->id)}}" method="post" id="form-{{$domain->id}}">
                        {{csrf_field()}}
                        {{method_field("DELETE")}}
                    </form>

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

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


 	                 </tbody> 
 	             </table> 

		
		@if(isset($_GET['domain']) and $_GET['domain'] != null)
		<br>
		<br>
		<div class="container">
			<div class="row justify-content-center">
			{{ $domains->appends(['domain'=>$_GET['domain']])->links() }}
		</div>
		</div>

		<br>
		<br>
		<br>
		
		@else
		<br>
		<br>
		<div class="container">
			<div class="row justify-content-center">
			{{ $domains->links() }}
		</div>
		</div>

		<br>
		<br>
		<br>

		@endif
 	          

 	         </div> 


@stop