@extends("layouts.dashboard")

@section("title", "Categories - Dashboard | TechnoBlog")

@section("dashboard_content")

	<div class="my-3 my-md-5">

		<div class="container">

			<div class="page-header">
				<h1 class="page-title">Categories</h1>
			</div>

			<div class="row">

				<div class="col-sm-12">
					<div class="card">

						<div class="card-header">
							<h3 class="card-title pt-2">
								List of categories
								<br>
								<p class="text-muted pt-2" style="font-size: 14px;">Note: If you will delete any category, &nbsp;all posts related to category will be deleted.</p>
							</h3>
							<a href="{{ route("dashboard.categories.create") }}" style='margin-left: auto; order: 2;'>
								<button type="button" class="btn btn-primary">Add New</button>
							</a>
						</div>

						<div class="table-responsive pt-5 pb-5">

							<table id="dttable" class="table table-hover table-outline table-vcenter text-nowrap card-table" style="width:100%">
								<thead>
									<tr>
										<th class="text-center">Name</th>
										<th class="text-center">Color</th>
										<th class="text-center">Status</th>
										<th class="text-center">Created Date</th>
										<th class="text-center">Actions</th>
									</tr>
								</thead>
								<tbody>
									@foreach ($categories as $category)
										<tr>
											<td>{{ $category->name }}</td>
											<td style="background: {{ $category->color }} ;"></td>
											<td class="text-center">
												@if ($category->is_active)
													Active
												@else
													Blocked
												@endif
											</td>
											<td class="text-center">{{ date('d.m.Y', strtotime($category->created_at)) }}</td>
											<td class="text-center">
												<div class="item-action dropdown">
													<a href="javascript:void(0)" data-toggle="dropdown" class="icon" aria-expanded="false"><i class="fe fe-more-vertical"></i></a>
													<div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; transform: translate3d(15px, 20px, 0px); top: 0px; left: 0px; will-change: transform;">

														<a href="{{ route("blog.category", ["category" => lcfirst($category->name)]) }}" target="_blank" class="dropdown-item"><i class="dropdown-icon fe fe-user"></i> View Posts </a>
														<a href="{{ route("dashboard.categories.edit", ["id" => $category->id]) }}" class="dropdown-item"><i class="dropdown-icon fe fe-edit"></i> Edit Category </a>

														@if ($category->is_active)
															<a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.categories.block", ["id" => $category->id]) }}" data-method="patch"><i class="dropdown-icon fe fe-lock"></i> Block </a>
														@else
															<a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.categories.unblock", ["id" => $category->id]) }}" data-method="patch"><i class="dropdown-icon fe fe-unlock"></i> Unblock </a>
														@endif

														<div class="dropdown-divider"></div>
														<a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.categories.destroy", ["id" => $category->id]) }}" data-method="delete"><i class="dropdown-icon fe fe-trash-2 text-danger"></i> Delete </a>

													</div>
												</div>
											</td>
										</tr>
									@endforeach
								</tbody>
							</table>

						</div>

					</div>

				</div>

			</div>

		</div>

	</div>

@endsection
