@extends('layouts.app')

@section('content')
<div class="panel panel-default">
    <div class="panel-heading">domains found by '{{$search_query}}'</div>
    

    <div class="panel-body">
       	<form method="post" action="{{ route('domains.search')}}" >
	    <input type="hidden" value="{{csrf_token()}}" name="_token" />
	        <div class="form-group">
	            <label for="title">Search domain by name, reference or customer:</label>
	            <input type="text" class="form-control" name="search" value="{{$search_query}}" />
	        </div>
	         <button type="submit" class="btn btn-primary">search</button>
	     </form>
        <table class="table">
         <thead>
        	<tr>
        		<th>Domain</th>
        		<th>Registry</th>
        		<th>Expired</th>
        		<th>customer</th>
        		<th></th>
        	</tr>
        </thead>
			@foreach( $domains as $domain )
				<tr @if( $domain->deleted_at != null ) style="background-color: #f8d7da;"  @endif>
					
					<td>
						<a href="{{ route('domains.show',$domain->id)}}">{{$domain->domain}}</a>
					</td>
					<td>
						{{$domain->registry}}
					</td>
					<td>
						{{$domain->expiry_date}}
					</td>
					<td>
						@if( $domain->customer_id == 0 )
						<div style="color: red">Not linked to customer</div>
						@else
						<div style="color: green">{{$domain->customer->xero_name}}</div>
						@endif
					</td>
					<td>
						<a  class="btn btn-primary" href="{{ route('domains.edit',$domain->id)}}">Edit</a>
					</td>
					
				</tr>
			@endforeach
		</table>

		
    </div>
</div>
@endsection