NIM_E31222518/resources/views/admin/banners/index.blade.php

125 lines
7.2 KiB
PHP

@extends('layouts.admin')
@section('content')
<div class="container px-6 mx-auto grid">
<h2 class="my-6 text-2xl font-semibold text-gray-700">
Manajemen Banner
</h2>
@if(session('success'))
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-4" role="alert">
<p>{{ session('success') }}</p>
</div>
@endif
@if(session('info'))
<div class="bg-blue-100 border-l-4 border-blue-500 text-blue-700 p-4 mb-4" role="alert">
<p>{{ session('info') }}</p>
</div>
@endif
<div class="flex justify-between items-center mb-6">
<div>
<a href="{{ route('admin.banners.create') }}" class="px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
Tambah Banner
</a>
</div>
</div>
<div class="w-full overflow-hidden rounded-lg shadow-xs">
<div class="w-full overflow-x-auto">
<table class="w-full whitespace-no-wrap">
<thead>
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b bg-gray-50">
<th class="px-4 py-3">Judul</th>
<th class="px-4 py-3">Gambar</th>
<th class="px-4 py-3">Urutan</th>
<th class="px-4 py-3">Periode</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3">Aksi</th>
</tr>
</thead>
<tbody class="bg-white divide-y">
@forelse($banners as $banner)
<tr class="text-gray-700">
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<div>
<p class="font-semibold">{{ $banner->judul }}</p>
<p class="text-xs text-gray-600">{{ $banner->deskripsi ? Str::limit($banner->deskripsi, 50) : 'Tidak ada deskripsi' }}</p>
</div>
</div>
</td>
<td class="px-4 py-3 text-sm">
@if($banner->gambar)
<img src="{{ Storage::url($banner->gambar) }}" alt="{{ $banner->judul }}" class="h-16 w-auto object-cover">
@else
Tidak ada gambar
@endif
</td>
<td class="px-4 py-3 text-sm">
<div class="flex items-center">
<span class="mr-2">{{ $banner->urutan }}</span>
<div class="flex flex-col">
<form action="{{ route('admin.banners.move-up', $banner) }}" method="POST">
@csrf
<button type="submit" class="text-gray-600 hover:text-gray-900 mb-1" title="Pindah Ke Atas">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
</button>
</form>
<form action="{{ route('admin.banners.move-down', $banner) }}" method="POST">
@csrf
<button type="submit" class="text-gray-600 hover:text-gray-900" title="Pindah Ke Bawah">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
</form>
</div>
</div>
</td>
<td class="px-4 py-3 text-sm">
<p>Mulai: {{ $banner->tanggal_mulai ? $banner->tanggal_mulai->format('d M Y') : 'Tidak diatur' }}</p>
<p>Selesai: {{ $banner->tanggal_selesai ? $banner->tanggal_selesai->format('d M Y') : 'Tidak diatur' }}</p>
</td>
<td class="px-4 py-3 text-sm">
<span class="px-2 py-1 font-semibold leading-tight rounded-full {{ $banner->aktif ? 'text-green-700 bg-green-100' : 'text-gray-700 bg-gray-100' }}">
{{ $banner->aktif ? 'Aktif' : 'Tidak Aktif' }}
</span>
</td>
<td class="px-4 py-3 text-sm">
<div class="flex items-center space-x-2">
<form action="{{ route('admin.banners.toggle', $banner) }}" method="POST">
@csrf
<button type="submit" class="px-2 py-1 text-xs font-medium leading-5 {{ $banner->aktif ? 'text-yellow-700 bg-yellow-100' : 'text-green-700 bg-green-100' }} rounded-lg focus:outline-none focus:shadow-outline-purple">
{{ $banner->aktif ? 'Nonaktifkan' : 'Aktifkan' }}
</button>
</form>
<a href="{{ route('admin.banners.edit', $banner) }}" class="px-2 py-1 text-xs font-medium leading-5 text-blue-700 bg-blue-100 rounded-lg focus:outline-none focus:shadow-outline-purple">
Edit
</a>
<form action="{{ route('admin.banners.destroy', $banner) }}" method="POST" onsubmit="return confirm('Apakah Anda yakin ingin menghapus banner ini?')">
@csrf
@method('DELETE')
<button type="submit" class="px-2 py-1 text-xs font-medium leading-5 text-red-700 bg-red-100 rounded-lg focus:outline-none focus:shadow-outline-purple">
Hapus
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-3 text-sm text-center">
Tidak ada banner yang tersedia.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection