create & read data tps
This commit is contained in:
parent
7be1b5d68e
commit
1f0d13c9ba
|
|
@ -35,6 +35,7 @@ public function store(Request $request)
|
|||
$request->validate([
|
||||
'kategori_tps_id' => 'required|exists:kategori_tps,id',
|
||||
'nama_tps' => 'required|string|max:255',
|
||||
'alamat_tps' => 'required|string|max:255',
|
||||
'status_tps' => 'required',
|
||||
'tahun_pembuatan' => 'required|numeric',
|
||||
'kapasitas_tps' => 'required',
|
||||
|
|
@ -53,6 +54,7 @@ public function store(Request $request)
|
|||
LokasiTps::create([
|
||||
'kategori_tps_id' => $request->kategori_tps_id,
|
||||
'nama_tps' => $request->nama_tps,
|
||||
'alamat_tps' => $request->alamat_tps,
|
||||
'status_tps' => $request->status_tps,
|
||||
'tahun_pembuatan' => $request->tahun_pembuatan,
|
||||
'kapasitas_tps' => $request->kapasitas_tps,
|
||||
|
|
@ -61,7 +63,7 @@ public function store(Request $request)
|
|||
'foto_tps' => $foto,
|
||||
]);
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
return redirect()->route('admin.tps.index')
|
||||
->with('success', 'Data TPS berhasil ditambahkan');
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +83,7 @@ public function update(Request $request, $id)
|
|||
$request->validate([
|
||||
'kategori_tps_id' => 'required|exists:kategori_tps,id',
|
||||
'nama_tps' => 'required|string|max:255',
|
||||
'alamat_tps' => 'required|string|max:255',
|
||||
'status_tps' => 'required',
|
||||
'tahun_pembuatan' => 'required|numeric',
|
||||
'kapasitas_tps' => 'required',
|
||||
|
|
@ -102,6 +105,7 @@ public function update(Request $request, $id)
|
|||
$tps->update([
|
||||
'kategori_tps_id' => $request->kategori_tps_id,
|
||||
'nama_tps' => $request->nama_tps,
|
||||
'alamat_tps' => $request->alamat_tps,
|
||||
'status_tps' => $request->status_tps,
|
||||
'tahun_pembuatan' => $request->tahun_pembuatan,
|
||||
'kapasitas_tps' => $request->kapasitas_tps,
|
||||
|
|
@ -110,7 +114,7 @@ public function update(Request $request, $id)
|
|||
'foto_tps' => $foto,
|
||||
]);
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
return redirect()->route('admin.tps.index')
|
||||
->with('success', 'Data TPS berhasil diperbarui');
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +128,7 @@ public function destroy($id)
|
|||
|
||||
$tps->delete();
|
||||
|
||||
return redirect()->route('tps.index')
|
||||
return redirect()->route('admin.tps.index')
|
||||
->with('success', 'Data TPS berhasil dihapus');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class LokasiTps extends Model
|
|||
protected $fillable = [
|
||||
'kategori_tps_id',
|
||||
'nama_tps',
|
||||
'alamat_tps',
|
||||
'status_tps',
|
||||
'tahun_pembuatan',
|
||||
'kapasitas_tps',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('lokasi_tps', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('lokasi_tps', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -19,6 +19,12 @@
|
|||
placeholder="Nama TPS" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Alamat</label>
|
||||
<input type="text" name="alamat" class="form-control"
|
||||
placeholder="Alamat TPS" required>
|
||||
</div>
|
||||
|
||||
<!-- KATEGORI TPS -->
|
||||
<div class="form-group">
|
||||
<label>Kategori TPS</label>
|
||||
|
|
|
|||
|
|
@ -1,62 +1,134 @@
|
|||
@extends('admin.template')
|
||||
|
||||
@section('content')
|
||||
<div class="content-wrapper">
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Basic form elements</h4>
|
||||
<h4 class="card-title">Edit TPS</h4>
|
||||
<p class="card-description">
|
||||
Basic form elements
|
||||
Form edit data Tempat Pembuangan Sampah
|
||||
</p>
|
||||
<form class="forms-sample">
|
||||
|
||||
<form action="{{ route('admin.tps.update', $tps->id) }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
class="forms-sample">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
{{-- Nama TPS --}}
|
||||
<div class="form-group">
|
||||
<label for="exampleInputName1">Name</label>
|
||||
<input type="text" class="form-control" id="exampleInputName1" placeholder="Name">
|
||||
<label>Nama TPS</label>
|
||||
<input type="text"
|
||||
name="nama_tps"
|
||||
class="form-control"
|
||||
value="{{ old('nama_tps', $tps->nama_tps) }}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
{{-- Alamat --}}
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail3">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
|
||||
<label>Alamat</label>
|
||||
<input type="text"
|
||||
name="alamat"
|
||||
class="form-control"
|
||||
value="{{ old('alamat', $tps->alamat) }}">
|
||||
</div>
|
||||
|
||||
{{-- Kategori TPS --}}
|
||||
<div class="form-group">
|
||||
<label for="exampleInputPassword4">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword4"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleSelectGender">Gender</label>
|
||||
<select class="form-control" id="exampleSelectGender">
|
||||
<option>Male</option>
|
||||
<option>Female</option>
|
||||
<label>Kategori TPS</label>
|
||||
<select name="kategori_tps_id" class="form-control" required>
|
||||
<option value="">-- Pilih Kategori --</option>
|
||||
@foreach($kategori as $item)
|
||||
<option value="{{ $item->id }}"
|
||||
{{ $tps->kategori_tps_id == $item->id ? 'selected' : '' }}>
|
||||
{{ $item->nama_kategori }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Status TPS --}}
|
||||
<div class="form-group">
|
||||
<label>File upload</label>
|
||||
<input type="file" name="img[]" class="file-upload-default">
|
||||
<label>Status TPS</label>
|
||||
<select name="status_tps" class="form-control" required>
|
||||
<option value="">-- Pilih Status --</option>
|
||||
<option value="Aktif"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Aktif' ? 'selected' : '' }}>
|
||||
Aktif
|
||||
</option>
|
||||
<option value="Tidak Aktif"
|
||||
{{ old('status_tps', $tps->status_tps) == 'Tidak Aktif' ? 'selected' : '' }}>
|
||||
Tidak Aktif
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Latitude --}}
|
||||
<div class="form-group">
|
||||
<label>Latitude</label>
|
||||
<input type="text"
|
||||
name="latitude"
|
||||
class="form-control"
|
||||
value="{{ old('latitude', $tps->latitude) }}">
|
||||
</div>
|
||||
|
||||
{{-- Longitude --}}
|
||||
<div class="form-group">
|
||||
<label>Longitude</label>
|
||||
<input type="text"
|
||||
name="longitude"
|
||||
class="form-control"
|
||||
value="{{ old('longitude', $tps->longitude) }}">
|
||||
</div>
|
||||
|
||||
{{-- Foto TPS --}}
|
||||
<div class="form-group">
|
||||
<label>Foto TPS</label>
|
||||
|
||||
<input type="file"
|
||||
name="foto_tps"
|
||||
class="file-upload-default">
|
||||
|
||||
<div class="input-group col-xs-12">
|
||||
<input type="text" class="form-control file-upload-info" disabled
|
||||
placeholder="Upload Image">
|
||||
<input type="text"
|
||||
class="form-control file-upload-info"
|
||||
disabled
|
||||
placeholder="Upload Foto TPS">
|
||||
<span class="input-group-append">
|
||||
<button class="file-upload-browse btn btn-primary" type="button">Upload</button>
|
||||
<button class="file-upload-browse btn btn-primary"
|
||||
type="button">
|
||||
Upload
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{{-- Foto Lama --}}
|
||||
@if($tps->foto_tps)
|
||||
<div class="mt-2">
|
||||
<img src="{{ asset('storage/'.$tps->foto_tps) }}"
|
||||
width="120"
|
||||
class="img-thumbnail">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputCity1">City</label>
|
||||
<input type="text" class="form-control" id="exampleInputCity1"
|
||||
placeholder="Location">
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="exampleTextarea1">Textarea</label>
|
||||
<textarea class="form-control" id="exampleTextarea1" rows="4"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mr-2">Submit</button>
|
||||
<button class="btn btn-light">Cancel</button>
|
||||
|
||||
{{-- Button --}}
|
||||
<button type="submit" class="btn btn-primary mr-2">
|
||||
Simpan Perubahan
|
||||
</button>
|
||||
<a href="{{ route('admin.tps.index') }}"
|
||||
class="btn btn-light">
|
||||
Batal
|
||||
</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Reference in New Issue