예제 #1
0
 public function run()
 {
     DB::table('peta')->delete();
     $faker = Faker::create();
     for ($i = 0; $i < 30; $i++) {
         Peta::create(['kategori_id' => rand(1, 4), 'nama_lokasi' => $faker->sentence($nbWords = 4), 'slug_nama' => str_slug($faker->sentence($nbWords = 4)), 'deskripsi_singkat' => $faker->text($maxNbChars = 250), 'deskripsi_lengkap' => $faker->text($maxNbChars = 400), 'alamat' => $faker->address, 'kecamatan_id' => rand(1, 78), 'latitude' => $faker->latitude, 'longitude' => $faker->longitude]);
     }
 }
예제 #2
0
 public function kabupatencagarbudaya($slug)
 {
     $lokasi = Kabupaten::with('kecamatan')->whereSlugNama($slug)->first();
     $kec = [];
     foreach ($lokasi->kecamatan as $q) {
         array_push($kec, $q->id);
     }
     $peta = Peta::with('kecamatan', 'kategori', 'foto')->whereIn('kecamatan_id', $kec)->orderBy('nama_lokasi', 'ASC')->get();
     return view('admin.lokasi.cagarbudaya')->withLokasi($lokasi)->withPeta($peta);
 }
예제 #3
0
 public function petakategori($id)
 {
     return response()->json(['error' => false, 'kategori' => Kategori::find($id)->pluck('nama_kategori'), 'peta' => Peta::with('kategori', 'kecamatan.kabupaten', 'foto')->where('kategori_id', $id)->get()]);
 }
예제 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $peta = Peta::find($id);
     $peta->delete();
     $foto = Foto::wherePetaId($id)->get();
     foreach ($foto as $q) {
         if (File::exists(public_path() . '/' . $q->url_foto)) {
             unlink($q->url_foto);
         }
     }
     Foto::wherePetaId($id)->delete();
     return redirect()->back()->with('message', 'Data peta cagar budaya berhasil dihapus');
 }