Update seeder sesuai dengan data asli
This commit is contained in:
parent
9e5026d18f
commit
0926843fc9
|
@ -74,6 +74,14 @@ public function update(Request $request, Curanmor $curanmor)
|
|||
*/
|
||||
public function destroy(Curanmor $curanmor)
|
||||
{
|
||||
//
|
||||
try{
|
||||
$hapus = Curanmor::find($curanmor);
|
||||
Curanmor::destroy($hapus);
|
||||
return redirect('/curanmor')->with('succes', 'Data Curanmor Berhasil Di Hapus');
|
||||
|
||||
}catch (\Exception $e){
|
||||
|
||||
return redirect('/curanmor')->with('error', 'Data Curanmor '. $curanmor->nama_kecamatan .' Gagal Di Hapus');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,45 +15,44 @@ class CuranmorSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$klasterId = Klaster::pluck('id');
|
||||
$kecamatanId1 = Kecamatan::where('id', '1')->first();
|
||||
$kecamatanId2 = Kecamatan::where('id', '2')->first();
|
||||
$kecamatanId3 = Kecamatan::where('id', '3')->first();
|
||||
$kecamatanId4 = Kecamatan::where('id', '4')->first();
|
||||
$kecamatanId5 = Kecamatan::where('id', '5')->first();
|
||||
$kecamatanId6 = Kecamatan::where('id', '6')->first();
|
||||
$klasterIds = Klaster::pluck('id'); // Ambil semua ID klaster
|
||||
$kecamatanIds = Kecamatan::pluck('id'); // Ambil semua ID kecamatan
|
||||
|
||||
|
||||
// Buat data kecamatan dengan klaster_id yang valid
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId1->id,
|
||||
'jumlah_curanmor' => 90,
|
||||
'klaster_id' => $klasterId->random(),// Ambil klaster secara acak
|
||||
]);
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId2->id,
|
||||
'jumlah_curanmor' => 76,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId3->id,
|
||||
'jumlah_curanmor' => 23,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId4->id,
|
||||
'jumlah_curanmor' => 87,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId5->id,
|
||||
'jumlah_curanmor' => 56,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId6->id,
|
||||
'jumlah_curanmor' => 54,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
// Data jumlah curanmor untuk setiap kecamatan
|
||||
$dataCuranmor= [
|
||||
1 => 5,
|
||||
2 => 4,
|
||||
3 => 2,
|
||||
4 => 22,
|
||||
5 => 4,
|
||||
6 => 18,
|
||||
7 => 0,
|
||||
8 => 37,
|
||||
9 => 9,
|
||||
10 => 3,
|
||||
11 => 2,
|
||||
12 => 13,
|
||||
13 => 1,
|
||||
14 => 21,
|
||||
15 => 14,
|
||||
16 => 4,
|
||||
17 => 10,
|
||||
18 => 0,
|
||||
19 => 1,
|
||||
20 => 10,
|
||||
21 => 1,
|
||||
22 => 2,
|
||||
23 => 15,
|
||||
24 => 4,
|
||||
];
|
||||
|
||||
// Looping untuk membuat data curanmor berdasarkan kecamatan
|
||||
foreach ($kecamatanIds as $kecamatanId) {
|
||||
Curanmor::create([
|
||||
'kecamatan_id' => $kecamatanId,
|
||||
'jumlah_curanmor' => $dataCuranmor[$kecamatanId], // Gunakan nilai default jika tidak ada data
|
||||
'klaster_id' => $klasterIds->random(), // Pilih klaster secara acak
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,45 +15,44 @@ class CurasSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$klasterId = Klaster::pluck('id');
|
||||
$kecamatanId1 = Kecamatan::where('id', '1')->first();
|
||||
$kecamatanId2 = Kecamatan::where('id', '2')->first();
|
||||
$kecamatanId3 = Kecamatan::where('id', '3')->first();
|
||||
$kecamatanId4 = Kecamatan::where('id', '4')->first();
|
||||
$kecamatanId5 = Kecamatan::where('id', '5')->first();
|
||||
$kecamatanId6 = Kecamatan::where('id', '6')->first();
|
||||
$klasterIds = Klaster::pluck('id'); // Ambil semua ID klaster
|
||||
$kecamatanIds = Kecamatan::pluck('id'); // Ambil semua ID kecamatan
|
||||
|
||||
|
||||
// Buat data kecamatan dengan klaster_id yang valid
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId1->id,
|
||||
'jumlah_curas' => 32,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId2->id,
|
||||
'jumlah_curas' => 77,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId3->id,
|
||||
'jumlah_curas' => 44,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId4->id,
|
||||
'jumlah_curas' => 5,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId5->id,
|
||||
'jumlah_curas' => 55,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId6->id,
|
||||
'jumlah_curas' => 43,
|
||||
'klaster_id' => $klasterId->random(), // Ambil klaster secara acak
|
||||
]);
|
||||
// Data jumlah curas untuk setiap kecamatan (sesuaikan dengan kebutuhan)
|
||||
$dataCuras = [
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 1,
|
||||
6 => 1,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
10 => 0,
|
||||
11 => 0,
|
||||
12 => 0,
|
||||
13 => 0,
|
||||
14 => 0,
|
||||
15 => 0,
|
||||
16 => 0,
|
||||
17 => 0,
|
||||
18 => 0,
|
||||
19 => 0,
|
||||
20 => 1,
|
||||
21 => 0,
|
||||
22 => 0,
|
||||
23 => 1,
|
||||
24 => 0,
|
||||
];
|
||||
|
||||
// Looping untuk membuat data curas berdasarkan kecamatan
|
||||
foreach ($kecamatanIds as $kecamatanId) {
|
||||
Curas::create([
|
||||
'kecamatan_id' => $kecamatanId,
|
||||
'jumlah_curas' => $dataCuras[$kecamatanId], // Gunakan nilai default jika tidak ada data
|
||||
'klaster_id' => $klasterIds->random(), // Pilih klaster secara acak
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,15 @@ class KecamatanSeeder extends Seeder
|
|||
public function run(): void
|
||||
{
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Leces',
|
||||
'nama_kecamatan'=> 'Bantaran',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Tegalsiwalan',
|
||||
'nama_kecamatan'=> 'Banyuanyar',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Besuk',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
|
@ -26,7 +30,7 @@ public function run(): void
|
|||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Kraksaan',
|
||||
'nama_kecamatan'=> 'Gading',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
|
@ -34,7 +38,75 @@ public function run(): void
|
|||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Gading',
|
||||
'nama_kecamatan'=> 'Kotaanyar',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Kraksaan',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Krenjengan',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Krucil',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Kuripan',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Leces',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Lumbang',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Maron',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Paiton',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Pakuniran',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Pajarakan',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Sukapura',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Sumber',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Sumberasih',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Tegalsiwalan',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Tiris',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Tongas',
|
||||
]);
|
||||
|
||||
Kecamatan::create([
|
||||
'nama_kecamatan'=> 'Wonomerto',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue