@extends('layouts.masterBackend')

@section('title', isset($page_article) ? $page_article : __('backend.article'))

@php
	use Carbon\Carbon;
@endphp

@section('content')


  <div class="container-fluid">

		<div class="row">
  		<div class="col-xs-12">
				<section id="message-banner" class="panel panel-primary">
				<header class="panel-heading">
						<h2>
							{{ isset($page_article) ? $page_article : __('backend.article') }}
						</h2>
					</header>
				<div class="panel-body">
					{{-- table --}}
					<div class="table-responsive">

		    			<table class="table table-hover article" id="table-dt">
					    <thead>
						    <tr>
						    	<th class="text-center">#</th>
						      <th class="text-center" style="width: 160px;">@lang('backend.banner')</th>
						      <th class="text-center">@lang('backend.title')</th>
					        <th class="text-center" style="min-width: 65px;">@lang('backend.action')</th>
						    </tr>
					    </thead>
					    <tbody>
					    	@foreach ($articles as $article)
					    		<tr>
					    			<td>{{ $loop->iteration }}</td>
					    			<td>
					    				<img src="{{ asset($storage_url.'img/article/'.$article->banner) }}" alt="" class="img-responsive thumb">
					    			</td>
					    			<td>
											<div class="wrapper">
												<h5>{{ $article->title }}</h5>
												<ul class="tag-wrapper">
													@foreach ($article->tags as $tag)
														<li class="tag">{{ $tag->name }}</li>
													@endforeach
												</ul>
												<p class="publisher">Created {{ Carbon::createFromTimestamp(strtotime($article->created_at))->diffForHumans() }} by {{ $article->user->name }}</p>
											</div>
					    			</td>
					    			<td>
					    				<a href="{{ route('articles.featured', $article) }}" class="btn {{ $article->featured ? 'btn-warning' : 'btn-default' }}">
					    					<i class="fa fa-star fa-fw"></i>
					    				</a>
					    				@if ($article->published==true)
					    					<a href="{{ route('articles.hide', $article) }}" class="btn btn-default">
						    					<i class="fa fa-check"></i>
						    				</a>
					    				@else
				    						<a href="{{ route('articles.publish', $article) }}" class="btn btn-default">
						    					<i class="fa fa-square-o"></i>
						    				</a>
					    				@endif
					    				<a href="{{ route('articles.edit', $article) }}" class="btn btn-default">
					    					<i class="fa fa-pencil"></i>
					    				</a>
					    				<a href="{{ route('articles.delete', $article) }}" class="btn btn-danger">
					    					<i class="fa fa-trash"></i>
					    				</a>
					    			</td>
					    		</tr>
					    	@endforeach

					    </tbody>
						</table>

	    			</div>
	    		{{-- /. table --}}
				</div>
				</section>

			</div>
		</div>

	</div>
@endsection

@section('script')
	<script>
		$("#table-dt").DataTable();
	</script>
@endsection
