@extends('Admin.master_page')

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

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

@section('content') 

<div class="table-responsive"> 

	<br>
 	<div >

 		<a href="{{route('blog.create')}}" class="button bg-theme-1 text-white mt-5" >Add New</a>
 	</div>

 	<br>
 	<table class="table">
 	 <thead>
 	  <tr>
 	    <th class="border-b-2 whitespace-nowrap">Image</th>
 	    <th class="border-b-2 whitespace-nowrap">Title</th>
 	     <th class="border-b-2 whitespace-nowrap">Description</th>
 	      <th class="border-b-2 whitespace-nowrap">Date</th>
 	      <th class="border-b-2 whitespace-nowrap">Action</th>
 	       </tr>
 	        </thead> 
 	        <tbody>
 	        @foreach($blogs as $blog)		
 	         <tr>
 	          <td class="border-b"><img src="/Images/{{ $blog->image }}" width="200" height="200"></td>
 	           <td class="border-b">{{ $blog->title }}</td>
 	            <td class="border-b">{!! html_entity_decode($blog->description) !!}</td>
 	             <td class="border-b">{{ $blog->date }}</td> 
 	            
				  <td>
					<form action="{{ route('blog.destroy', $blog->id) }}" method="post"
						id="form-{{ $blog->id }}">
						{{ csrf_field() }}
						{{ method_field('DELETE') }}
					</form>

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

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


 	                 </tbody> 
 	             </table> 

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

		<br>
		<br>
		<br>

 	         </div> 


@stop