MIF_E31212366/resources/views/kecamatan.blade.php

140 lines
6.6 KiB
PHP

@extends('layouts.master')
@section('content')
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Data Kecamatan Banyuwangi</h1>
<button type="button" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm" data-toggle="modal" data-target="#tambahKecamatanModal">
<i class="fas fa-plus fa-sm text-white-50"></i> Tambah
</button>
</div>
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered data-table" id="myTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Kecamatan</th>
<th>Jumlah Penduduk</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
@foreach ($dataKecamatan as $data)
<tr>
<td>{{ $data->nama_kecamatan }}</td>
<td>{{ $data->jumlah_penduduk }}</td>
<td>{{ $data->latitude }}</td>
<td>{{ $data->longitude }}</td>
<td>
{{-- <button class="btn btn-sm btn-primary editBtn" data-id="{{ $data->id }}" data-nama="{{ $data->nama_kecamatan }}" data-penduduk="{{ $data->jumlah_penduduk }}" data-lat="{{ $data->latitude }}" data-lng="{{ $data->longitude }}">Edit</button> --}}
<button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#edit{{$data->id}}">Edit</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Tambah Kecamatan Modal -->
<div class="modal fade" id="tambahKecamatanModal" tabindex="-1" role="dialog" aria-labelledby="tambahKecamatanModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="tambahKecamatanModalLabel">Tambah Kecamatan</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<!-- Formulir Tambah Kecamatan -->
<form method="POST" action="{{ route('kecamatan.store') }}">
@csrf
<div class="form-group">
<label for="nama_kecamatan">Nama Kecamatan:</label>
<input class="form-control" type="text" id="nama_kecamatan" name="nama_kecamatan" required>
</div>
<div class="form-group">
<label for="jumlah_penduduk">Jumlah Penduduk:</label>
<input class="form-control" type="number" id="jumlah_penduduk" name="jumlah_penduduk" required>
</div>
<div class="form-group">
<label for="latitude">Latitude:</label>
<input class="form-control" type="text" id="latitude" name="latitude" required>
</div>
<div class="form-group">
<label for="longitude">Longitude:</label>
<input class="form-control" type="text" id="longitude" name="longitude" required>
</div>
<div class="mt-2">
<button class="btn btn-primary" type="submit">Simpan</button>
</div>
</form>
<!-- Akhir Formulir Tambah Kecamatan -->
</div>
</div>
</div>
</div>
<!-- Edit Kecamatan Modal -->
@foreach ($dataKecamatan as $item)
<div class="modal fade" id="edit{{$item->id}}" tabindex="-1" role="dialog" aria-labelledby="editKecamatanModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editKecamatanModalLabel">Edit Data Kecamatan</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<!-- Formulir Edit Kecamatan -->
<form id="editKecamatanForm" method="POST" action="{{ route('kecamatan.update', $item->id) }}">
@csrf
@method('PUT')
{{-- <input type="hidden" id="edit_id" name="id"> --}}
<div class="form-group">
<label for="edit_nama_kecamatan">Nama Kecamatan:</label>
<input class="form-control" type="text" id="edit_nama_kecamatan" name="nama_kecamatan" value="{{$item->nama_kecamatan}}" required>
</div>
<div class="form-group">
<label for="edit_jumlah_penduduk">Jumlah Penduduk:</label>
<input class="form-control" type="number" id="edit_jumlah_penduduk" name="jumlah_penduduk" value="{{$item->jumlah_penduduk}}" required>
</div>
<div class="form-group">
<label for="edit_latitude">Latitude:</label>
<input class="form-control" type="text" id="edit_latitude" name="latitude" value="{{$item->latitude}}" required>
</div>
<div class="form-group">
<label for="edit_longitude">Longitude:</label>
<input class="form-control" type="text" id="edit_longitude" name="longitude" value="{{$item->longitude}}" required>
</div>
<div class="mt-2">
<button class="btn btn-primary" type="submit">Update</button>
</div>
</form>
<!-- Akhir Formulir Edit Kecamatan -->
</div>
</div>
</div>
</div>
@endforeach
@endsection
@push('plugin-scripts')
@endpush
@section('js')
@endsection