pertama
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
@extends('layouts.admin.main')
|
||||
|
||||
@push('styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.3.8/css/dataTables.bootstrap5.min.css" />
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="mb-3">
|
||||
<h1 class="h3 d-inline align-middle">Media</h1>
|
||||
</div>
|
||||
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
<strong>{{ session('success') }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header pb-0">
|
||||
<div class="card-actions float-end">
|
||||
<a href="{{ route('admin.contents.media.create') }}" class="btn btn-sm btn-secondary"><i class="align-middle me-2" data-feather="plus"></i>Tambah</a>
|
||||
</div>
|
||||
<h4 class="card-title mb-0">Daftar Media</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="table-media" class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Preview</th>
|
||||
<th>Nama File</th>
|
||||
<th>Type</th>
|
||||
<th>Ukuran</th>
|
||||
<th class="text-end">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($media as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td style="width: 100px;">
|
||||
@if (str_starts_with($item->mime_type, 'image/'))
|
||||
<img src="{{ asset('storage/' . $item->path) }}" alt="{{ $item->alt ?? $item->filename }}" class="img-fluid" style="max-height: 60px;" />
|
||||
@else
|
||||
<span class="badge bg-secondary">{{ strtoupper($item->extension) }}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $item->filename }}</td>
|
||||
<td>{{ $item->mime_type }}</td>
|
||||
<td>{{ number_format($item->size / 1024, 2) }} KB</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ route('admin.contents.media.show', $item->id) }}" class="btn btn-sm btn-info">
|
||||
<i class="align-middle me-2" data-feather="eye"></i>Detail
|
||||
</a>
|
||||
<a href="{{ route('admin.contents.media.edit', $item->id) }}" class="btn btn-sm btn-primary">
|
||||
<i class="align-middle me-2" data-feather="edit"></i>Edit
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-danger delete"
|
||||
data-id="{{ $item->id }}" data-name="{{ $item->filename }}">
|
||||
<i class="align-middle me-2" data-feather="trash"></i>Hapus
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{{ $media->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="delete-modal" tabindex="-1" aria-labelledby="delete-modal-label" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="delete-modal-label">Hapus Media</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Apakah anda yakin ingin menghapus file media: <b><span id="media-name"></span></b>?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">
|
||||
<i class="align-middle me-2" data-feather="x"></i>Batal
|
||||
</button>
|
||||
<form id="form-delete" action="" method="POST">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-danger">
|
||||
<i class="align-middle me-2" data-feather="trash"></i>Hapus
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.datatables.net/2.3.8/js/dataTables.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.3.8/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$('#table-media').DataTable({
|
||||
paging: true,
|
||||
ordering: true,
|
||||
info: true,
|
||||
searching: true,
|
||||
});
|
||||
|
||||
$('.delete').click(function() {
|
||||
let id = $(this).data('id');
|
||||
let name = $(this).data('name');
|
||||
$('#media-name').text(name);
|
||||
|
||||
let url = "{{ route('admin.contents.media.destroy', ':id') }}";
|
||||
url = url.replace(':id', id);
|
||||
$('#form-delete').attr('action', url);
|
||||
$('#delete-modal').modal('show');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user