database-pertani-web/resources/views/master/tanaman/index.blade.php
2026-03-10 14:05:41 +07:00

83 lines
4.4 KiB
PHP

@extends('layout.main')
@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
<div class="card">
<div class="card-header border-bottom">
<h5 class="card-title mb-0">Data Map Tanaman</h5>
</div>
<div class="card-body border-bottom pt-4">
<form method="GET" action="{{ route('tanaman.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
<div class="col-md-auto">
<div class="d-flex align-items-center">
<label class="me-2 text-nowrap">Show</label>
<select name="per_page" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
<option value="10" {{ request('per_page') == 10 ? 'selected' : '' }}>10</option>
<option value="25" {{ request('per_page') == 25 ? 'selected' : '' }}>25</option>
</select>
<label class="ms-2 text-nowrap">entries</label>
</div>
</div>
<div class="col-md-auto d-flex gap-2">
<div class="input-group input-group-sm w-auto">
<input type="text" name="search" class="form-control" placeholder="Cari Tanaman / Lahan..." value="{{ request('search') }}">
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
</div>
<a href="{{ route('tanaman.create') }}" class="btn btn-sm btn-primary">
<i class="ti tabler-plus me-1"></i> Tambah Tanaman
</a>
</div>
</form>
</div>
<div class="table-responsive text-nowrap">
<table class="table table-hover">
<thead class="border-top">
<tr>
<th>No</th>
<th>Nama Tanaman</th>
<th>Komoditas</th>
<th>Lahan</th>
<th>Kondisi</th>
<th>Koordinat</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@forelse($tanaman as $index => $item)
<tr>
<td>{{ $tanaman->firstItem() + $index }}</td>
<td><span class="text-heading fw-medium">{{ $item->nama }}</span></td>
<td>{{ $item->komoditas->nama ?? '-' }}</td>
<td>{{ $item->lahan->nama ?? '-' }}</td>
<td>
@if($item->kondisi_tanaman == 'sehat')
<span class="badge bg-label-success">Sehat</span>
@elseif($item->kondisi_tanaman == 'sakit')
<span class="badge bg-label-warning">Sakit</span>
@else
<span class="badge bg-label-danger">Mati</span>
@endif
</td>
<td><small>{{ $item->latitude }},<br>{{ $item->longitude }}</small></td>
<td>
<div class="d-flex align-items-center">
<a href="#" class="btn btn-icon btn-text-secondary rounded-pill"><i class="ti tabler-edit ti-md"></i></a>
<a href="#" class="btn btn-icon btn-text-secondary rounded-pill"><i class="ti tabler-trash ti-md"></i></a>
<a href="{{ route('tanaman.show', $item->id) }}" class="btn btn-icon btn-text-secondary rounded-pill"><i class="ti tabler-eye ti-md"></i></a>
</div>
</td>
</tr>
@empty
<tr><td colspan="7" class="text-center py-4">Tidak ada data tanaman ditemukan.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="card-footer d-flex justify-content-center justify-content-md-end border-top">
{{ $tanaman->appends(request()->query())->links('pagination::bootstrap-5') }}
</div>
</div>
</div>
@endsection