From f7fc4278367fee99e649f91a6581406cfa22c793 Mon Sep 17 00:00:00 2001 From: ilhamwara Date: Wed, 13 Aug 2025 10:51:47 +0700 Subject: [PATCH] update --- app/Http/Controllers/FrontController.php | 23 ++ .../Modules/Konten/GaleriController.php | 130 ++++++++++ .../Modules/Konten/KegiatanController.php | 227 ++++++++++++++++++ app/Models/Konten/Galeri.php | 14 ++ app/Models/Konten/ImageGaleri.php | 19 ++ app/Models/Konten/Kegiatan.php | 14 ++ ...25_08_08_085907_create_kegiatans_table.php | 32 +++ ...2025_08_08_085932_create_galeris_table.php | 29 +++ ...8_08_090458_create_image_galeris_table.php | 30 +++ resources/views/index.blade.php | 52 ++-- resources/views/kegiatan.blade.php | 88 +------ .../modules/konten/galeri/form.blade.php | 90 +++++++ .../modules/konten/galeri/index.blade.php | 111 +++++++++ .../modules/konten/kegiatan/form.blade.php | 128 ++++++++++ .../modules/konten/kegiatan/index.blade.php | 112 +++++++++ routes/modules/modules.php | 19 ++ routes/web.php | 27 +-- 17 files changed, 1010 insertions(+), 135 deletions(-) create mode 100644 app/Http/Controllers/FrontController.php create mode 100644 app/Http/Controllers/Modules/Konten/GaleriController.php create mode 100644 app/Http/Controllers/Modules/Konten/KegiatanController.php create mode 100644 app/Models/Konten/Galeri.php create mode 100644 app/Models/Konten/ImageGaleri.php create mode 100644 app/Models/Konten/Kegiatan.php create mode 100644 database/migrations/2025_08_08_085907_create_kegiatans_table.php create mode 100644 database/migrations/2025_08_08_085932_create_galeris_table.php create mode 100644 database/migrations/2025_08_08_090458_create_image_galeris_table.php create mode 100644 resources/views/modules/konten/galeri/form.blade.php create mode 100644 resources/views/modules/konten/galeri/index.blade.php create mode 100644 resources/views/modules/konten/kegiatan/form.blade.php create mode 100644 resources/views/modules/konten/kegiatan/index.blade.php diff --git a/app/Http/Controllers/FrontController.php b/app/Http/Controllers/FrontController.php new file mode 100644 index 0000000..5c28139 --- /dev/null +++ b/app/Http/Controllers/FrontController.php @@ -0,0 +1,23 @@ +limit(5)->get(); + return view('index',$data); + } + function sekolah() { + return view('sekolah'); + } + function kegiatan() { + $data['kegiatan'] = Kegiatan::orderBy('KegiatanId','DESC')->paginate(8); + return view('kegiatan',$data); + } + function galeri() { + return view('galeri'); + } +} diff --git a/app/Http/Controllers/Modules/Konten/GaleriController.php b/app/Http/Controllers/Modules/Konten/GaleriController.php new file mode 100644 index 0000000..e189ab3 --- /dev/null +++ b/app/Http/Controllers/Modules/Konten/GaleriController.php @@ -0,0 +1,130 @@ + 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Galeri','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + + return view($this->template.'.index',$data); + } + + public function grid(Request $request) + { + $data = Galeri::all(); + + + foreach ($data as $key => $row) { + + $action = ''; + + if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){ + $action .= ''; + $action .= ''; + } + + $_data[] = [ + 'no' => $key+1, + 'id' => encode_id($row->GaleriId), + 'judul' => $row->judul, + 'action' => $action, + ]; + + } + + return response()->json($_data); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $data['breadcrumbs'] = [ + ['name' => 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Galeri','url' => url('konten/galeri')], + ['name' => 'Tambah Galeri','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + + return view($this->template.'.form',$data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + $data['breadcrumbs'] = [ + ['name' => 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Galeri','url' => url('konten/galeri')], + ['name' => 'Edit Galeri','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + $data['item'] = Galeri::find(decode_id($id)); + + return view($this->template.'.form',$data); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + + } + + /** + * Remove the specified resource from storage. + */ + public function delete($id) + { + $keyId = decode_id($id); + $form = Galeri::where('GaleriId',$keyId)->delete(); + + return response()->json(['success' => true,'message' => 'Berhasil update data','type' => 'success']); + } +} diff --git a/app/Http/Controllers/Modules/Konten/KegiatanController.php b/app/Http/Controllers/Modules/Konten/KegiatanController.php new file mode 100644 index 0000000..3499b6f --- /dev/null +++ b/app/Http/Controllers/Modules/Konten/KegiatanController.php @@ -0,0 +1,227 @@ + 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Kegiatan','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + + return view($this->template.'.index',$data); + } + + public function grid(Request $request) + { + $data = Kegiatan::all(); + + + foreach ($data as $key => $row) { + + $action = ''; + + if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){ + $action .= ''; + $action .= ''; + } + + $_data[] = [ + 'no' => $key+1, + 'id' => encode_id($row->KegiatanId), + 'judul' => $row->judul, + 'created_at' => dateTime($row->created_at), + 'image' => '', + 'action' => $action, + ]; + + } + + return response()->json($_data); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $data['breadcrumbs'] = [ + ['name' => 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Kegiatan','url' => url('konten/kegiatan')], + ['name' => 'Tambah Kegiatan','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + + return view($this->template.'.form',$data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // dd($request->all()); + try { + if(@$request->secure_id){ + $keyId = decode_id($request->secure_id); + $keg = Kegiatan::find($keyId); + $keg->slug = \Str::slug($request->judul); + $keg->judul = $request->judul; + $keg->kategori = $request->kategori; + $keg->body = $request->body; + + if (@$request->hasFile('image')) { + $file = $request->file('image'); + $destinationPath = public_path('uploads/kegiatan'); + $current = Carbon::now()->format('Y/m/d'); + $path = $destinationPath . '/' . $current; + $fileName = $file->getClientOriginalName(); + $fileMime = $file->getClientMimeType(); + $fileExtension = $file->getClientOriginalExtension(); + $fileSize = $file->getSize(); + if(($fileExtension != 'jpg') && ($fileExtension != 'jpeg') && ($fileExtension != 'png')){ + return redirect()->back()->with([ + 'message' => 'Maaf File Harus Berupa PNG,JPEG,JPG!', + 'type' => "error" + ]); + } + $newFilename = session('id').'_'.uniqid('file_') . '.' . $fileExtension; + + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $filePathTim = 'kegiatan/' . $current . '/' . $newFilename; + $uploaded = $file->move($path, $newFilename); + $keg->image = $filePathTim; + } + $keg->save(); + }else{ + $keg = new Kegiatan; + $keg->slug = \Str::slug($request->judul); + $keg->judul = $request->judul; + $keg->kategori = $request->kategori; + $keg->body = $request->body; + + if (@$request->hasFile('image')) { + $file = $request->file('image'); + $destinationPath = public_path('uploads/kegiatan'); + $current = Carbon::now()->format('Y/m/d'); + $path = $destinationPath . '/' . $current; + $fileName = $file->getClientOriginalName(); + $fileMime = $file->getClientMimeType(); + $fileExtension = $file->getClientOriginalExtension(); + $fileSize = $file->getSize(); + if(($fileExtension != 'jpg') && ($fileExtension != 'jpeg') && ($fileExtension != 'png')){ + return redirect()->back()->with([ + 'message' => 'Maaf File Harus Berupa PNG,JPEG,JPG!', + 'type' => "error" + ]); + } + $newFilename = session('id').'_'.uniqid('file_') . '.' . $fileExtension; + + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $filePathTim = 'kegiatan/' . $current . '/' . $newFilename; + $uploaded = $file->move($path, $newFilename); + $keg->image = $filePathTim; + } + $keg->save(); + } + return redirect()->back()->with([ + 'message' => 'Berhasil update data', + 'type' => 'success', + ]); + } catch (Exception $e) { + return redirect()->back()->with([ + 'message' => $e->getMessage(), + 'type' => "error" + ]); + } + + + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + $data['breadcrumbs'] = [ + ['name' => 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Kegiatan','url' => url('konten/kegiatan')], + ['name' => 'Edit Kegiatan','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + $data['item'] = Kegiatan::find(decode_id($id)); + + return view($this->template.'.form',$data); + } + + /** + * Update the specified resource in storage. + */ + public function update($id) + { + $data['breadcrumbs'] = [ + ['name' => 'Dashboard','url' => url('dashboard')], + ['name' => 'Konten'], + ['name' => 'Kegiatan','url' => url('konten/kegiatan')], + ['name' => 'Tambah Kegiatan','active' => true], + ]; + + $data['route'] = $this->route; + $data['title'] = $this->title; + $data['item'] = Kegiatan::find(decode_id($id)); + $data['keyId'] = $id; + + return view($this->template.'.form',$data); + } + + /** + * Remove the specified resource from storage. + */ + public function delete($id) + { + $keyId = decode_id($id); + $form = Kegiatan::where('KegiatanId',$keyId)->delete(); + + return response()->json(['success' => true,'message' => 'Berhasil update data','type' => 'success']); + } +} diff --git a/app/Models/Konten/Galeri.php b/app/Models/Konten/Galeri.php new file mode 100644 index 0000000..16ce650 --- /dev/null +++ b/app/Models/Konten/Galeri.php @@ -0,0 +1,14 @@ +belongsTo(\App\Models\Galeri::class,'galeri_id'); + } +} diff --git a/app/Models/Konten/Kegiatan.php b/app/Models/Konten/Kegiatan.php new file mode 100644 index 0000000..3b095bd --- /dev/null +++ b/app/Models/Konten/Kegiatan.php @@ -0,0 +1,14 @@ +id('KegiatanId'); + $table->string('slug')->nullable(); + $table->string('judul')->nullable(); + $table->text('body')->nullable(); + $table->string('kategori')->nullable(); + $table->string('image')->nullable(); + $table->timestampsTz(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('kegiatans'); + } +}; diff --git a/database/migrations/2025_08_08_085932_create_galeris_table.php b/database/migrations/2025_08_08_085932_create_galeris_table.php new file mode 100644 index 0000000..d63ea7f --- /dev/null +++ b/database/migrations/2025_08_08_085932_create_galeris_table.php @@ -0,0 +1,29 @@ +id('GaleriId'); + $table->string('judul')->nullable(); + $table->text('deskripsi')->nullable(); + $table->timestampsTz(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('galeris'); + } +}; diff --git a/database/migrations/2025_08_08_090458_create_image_galeris_table.php b/database/migrations/2025_08_08_090458_create_image_galeris_table.php new file mode 100644 index 0000000..21c3167 --- /dev/null +++ b/database/migrations/2025_08_08_090458_create_image_galeris_table.php @@ -0,0 +1,30 @@ +id('ImagegaleriId'); + $table->integer('galeri_id'); + $table->timestampsTz(); + + $table->foreign('galeri_id')->references('GaleriId')->on('galeri')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('image_galeris'); + } +}; diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index bf719d2..6f8a882 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -171,58 +171,34 @@
- +
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 + Kegiatan {{ $kegiatan[0]->kategori }} + {{ date('D',strtotime($kegiatan[0]->created_at)) }}, {{ date('d M Y',strtotime($kegiatan[0]->created_at)) }}
-

Kagiatan Program Sekolah Adiwiyata Provinsi SMPN 197

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara menjalani sidang Tindak Pidana Ringan (Tipiring) di Pengadilan Negeri Jakarta Barat pada Selasa (29/7). -

- +

{{ $kegiatan[0]->judul }}

+
+ {!! substr(strip_tags($kegiatan[0]->body),0,1000) !!} +
+
Baca Selengkapnya
diff --git a/resources/views/kegiatan.blade.php b/resources/views/kegiatan.blade.php index 00961b7..e271b58 100644 --- a/resources/views/kegiatan.blade.php +++ b/resources/views/kegiatan.blade.php @@ -90,90 +90,28 @@
- + @foreach($kegiatan as $dataKeg)
- +
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 + Kegiatan {{ $dataKeg->kategori }} + {{ date('D',strtotime($dataKeg->created_at)) }}, {{ date('d M Y',strtotime($dataKeg->created_at)) }}
-

Kagiatan Program Sekolah Adiwiyata Provinsi SMPN 197

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara -

- +

{{ $dataKeg->judul }}

+
+ {!! substr(strip_tags($dataKeg->body),0,200) !!} +
+
Baca Selengkapnya
-
-
- -
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 -
-

Kagiatan Program Sekolah Adiwiyata SDN 15 Ciracas

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara -

- - Baca Selengkapnya - -
-
-
-
- -
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 -
-

Kagiatan Program Sekolah Adiwiyata SMAN 67 Jakarta

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara -

- - Baca Selengkapnya - -
-
-
-
- -
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 -
-

Kagiatan Program Sekolah Adiwiyata MAN 2 Jakarta

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara -

- - Baca Selengkapnya - -
-
-
-
- -
- Kegiatan Provinsi - Jumat, 1 Agustus 2025 -
-

Kagiatan Program Sekolah Adiwiyata SDN 05 Pondok Kelapa

-

- JAKARTA – Sebanyak empat pelanggar Peraturan Daerah (Perda) Provinsi DKI Jakarta Nomor 2 Tahun 2005 tentang Pengendalian Pencemaran Udara -

- - Baca Selengkapnya - -
-
- + @endforeach
- +
+
+ {!! $kegiatan->links() !!}