Skip to content

Commit

Permalink
Rilis 2410 (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
habibie11 authored Oct 1, 2024
2 parents d012524 + 3241c57 commit 3524f16
Show file tree
Hide file tree
Showing 117 changed files with 3,622 additions and 862 deletions.
9 changes: 9 additions & 0 deletions app/Enums/MenuTipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ final class MenuTipe extends Enum
public const STATISTIK = 3;
public const POTENSI = 4;
public const UNDUHAN = 5;
public const PUBLIKASI = 6;
public const EKSTERNAL = 0;


Expand All @@ -57,6 +58,7 @@ public static function all(): array
self::STATISTIK => 'Statistik',
self::POTENSI => 'Potensi',
self::UNDUHAN => 'Unduhan',
self::PUBLIKASI => 'Publikasi',
self::EKSTERNAL => 'Eksternal',
];
}
Expand Down Expand Up @@ -103,4 +105,11 @@ public static function getUnduhan(): array
'dokumen' => 'Dokumen',
];
}

public static function getPublikasi(): array
{
return [
'galeri' => 'Galeri',
];
}
}
19 changes: 5 additions & 14 deletions app/Http/Controllers/BackEnd/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@

use App\Models\Event;
use Illuminate\Support\Carbon;
use App\Traits\HandlesFileUpload;
use App\Http\Requests\EventRequest;
use Illuminate\Support\Facades\File;
use Yajra\DataTables\Facades\DataTables;
use App\Http\Controllers\BackEndController;

class EventController extends BackEndController
{
use HandlesFileUpload;

public function index()
{
$page_title = 'Event';
Expand Down Expand Up @@ -121,15 +124,7 @@ public function update(EventRequest $request, Event $event)
try {
$waktu = explode('-', $request->waktu);
$input = $request->all();

if ($request->hasFile('attachment')) {
$lampiran = $request->file('attachment');
$fileName = $lampiran->getClientOriginalName();
$path = 'event/'.$event->id.'/';
File::deleteDirectory(base_path('public/'.$path)); //hapus directory sebelumnya
$lampiran->move(base_path('public/'.$path), $fileName);
$input['attachment'] = $path.$fileName;
}
$this->handleFileUpload($request, $input, 'attachment', "event/{$event->id}");
$input['end'] = date('Y-m-d H:i', strtotime($waktu[1]));
$input['start'] = date('Y-m-d H:i', strtotime($waktu[0]));

Expand All @@ -150,11 +145,7 @@ public function destroy(Event $event)
}

try {
if ($event->delete()) {
if ($event->attachment != null && File::exists(base_path('public/'.$event->attachment))) {
unlink(base_path('public/'.$event->attachment));
}
}
$event->delete();
} catch (\Exception $e) {
report($e);

Expand Down
171 changes: 162 additions & 9 deletions app/Http/Controllers/FrontEnd/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@

namespace App\Http\Controllers\FrontEnd;

use App\Facades\Counter;
use App\Http\Controllers\FrontEndController;
use App\Models\Event;
use App\Models\Artikel;
use App\Facades\Counter;
use App\Models\DataDesa;
use App\Models\Event;
use Illuminate\Http\Request;
use PhpParser\Node\Stmt\Catch_;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
use willvincent\Feeds\Facades\FeedsFacade;
use App\Http\Controllers\FrontEndController;
use Jenssegers\Agent\Agent;

class PageController extends FrontEndController
{
Expand Down Expand Up @@ -72,7 +75,32 @@ public function beritaDesa()

private function getFeeds()
{
return getFeeds();
$all_desa = DataDesa::websiteUrl()->get()
->map(function ($desa) {
return $desa->website_url_feed;
})->all();

$feeds = [];
foreach ($all_desa as $desa) {
$getFeeds = FeedsFacade::make($desa['website'], 5, true);
foreach ($getFeeds->get_items() as $item) {
$feeds[] = [
'desa_id' => $desa['desa_id'],
'nama_desa' => $desa['nama'],
'feed_link' => $item->get_feed()->get_permalink(),
'feed_title' => $item->get_feed()->get_title(),
'link' => $item->get_link(),
'date' => \Carbon\Carbon::parse($item->get_date('U')),
'author' => $item->get_author()->get_name() ?? 'Administrator',
'title' => $item->get_title(),
'image' => get_tag_image($item->get_description()),
'description' => strip_tags(substr(str_replace(['&', 'nbsp;', '[...]'], '', $item->get_description()), 0, 250) . '[...]'),
'content' => $item->get_content(),
];
}
}

return $feeds ?? null;
}

public function filterFeeds(Request $request)
Expand Down Expand Up @@ -142,7 +170,7 @@ public function DesaShow($slug)
// Counter::count('desa.show');

$desa = DataDesa::nama($slug)->firstOrFail();
$page_title = 'Desa '.$desa->nama;
$page_title = 'Desa ' . $desa->nama;
$page_description = 'Data Desa';

return view('pages.desa.desa_show', compact('page_title', 'page_description', 'desa'));
Expand All @@ -153,16 +181,141 @@ public function refresh_captcha()
return response()->json(['captcha' => captcha_img('mini')]);
}

public function detailBerita($slug)
public function detailBerita($slug, Request $request)
{
$artikel = Artikel::where('slug', $slug)->status()->firstOrFail();
// Temukan artikel berdasarkan slug
$artikel = Artikel::where('slug', $slug)
->with(['comments' => function ($query) use ($request) {
// Ambil komentar yang di-approve atau yang milik user dari session
$userCommentIds = $request->session()->get('session_user_comments', []);

// Ambil komentar utama (tanpa parent) yang di-approve atau yang dimiliki oleh user
$query->whereNull('comment_id')
->where(function ($query) use ($userCommentIds) {
$query->where('status', 'enable')
->orWhereIn('id', $userCommentIds);
})
->with(['replies' => function ($query) use ($userCommentIds) {
// Ambil balasan yang di-approve atau yang milik user
$query->where(function ($query) use ($userCommentIds) {
$query->where('status', 'enable')
->orWhereIn('id', $userCommentIds);
});
}]);
}])
->firstOrFail();

$page_title = $artikel->judul;
$page_description = substr($artikel->isi, 0, 300).' ...';
$page_description = substr($artikel->isi, 0, 300) . ' ...';
$page_image = $artikel->gambar;

return view('pages.berita.detail', compact('page_title', 'page_description', 'page_image', 'artikel'));
// Ambil komentar utama yang terkait dengan artikel ini
$comments = $artikel->comments;

return view('pages.berita.detail', compact('page_title', 'page_description', 'page_image', 'artikel', 'comments'));
}


public function kirimKomentar(Request $request)
{

// Validasi input
$validated = $request->validate([
'nama' => 'required|string|max:255',
'email' => 'required|email|max:255',
'body' => 'required|string',
'das_artikel_id' => 'required|exists:das_artikel,id',
'captcha_main' => 'required|captcha',
]);

try {
// Mendeteksi IP address
$ipAddress = $request->ip();

// Mendeteksi device menggunakan jenssegers/agent
$agent = new Agent();
$device = $agent->device() ?: 'Desktop';
$platform = $agent->platform() ?: 'Unknown Platform';
$browser = $agent->browser() ?: 'Unknown Browser';

// Format informasi device
$deviceInfo = "{$device} on {$platform} using {$browser}";

// Simpan komentar baru
$comment = \App\Models\Comment::create([
'nama' => $validated['nama'],
'email' => $validated['email'],
'body' => $validated['body'],
'status' => 'disable', // Set status default ke 'disable' untuk moderasi
'das_artikel_id' => $validated['das_artikel_id'],
'comment_id' => $request->input('comment_id', null), // Jika ini adalah balasan
'ip_address' => $ipAddress,
'device' => $deviceInfo,
]);

// Simpan comment_id ke dalam session agar user bisa melihat komentarnya sendiri
$request->session()->push('session_user_comments', $comment->id);

// Redirect dengan pesan sukses
return redirect()->back()->with('success', 'Komentar Anda telah ditambahkan.');
} catch (\Throwable $th) {
// Penanganan kesalahan
return redirect()->back()->withInput($request->all())->withErrors([$th->getMessage()]);
}
}

public function modalKirimBalasan(Request $request)
{
$commentId = $request->input('comment_id');
$artikelId = $request->input('artikel_id');
return view('pages.berita.comment', compact('commentId', 'artikelId'));
}

public function kirimBalasan(Request $request)
{
$request->validate([
'nama' => 'required|string|max:255',
'email' => 'required|email|max:255',
'body' => 'required|string',
'captcha_main' => 'required|captcha',
'das_artikel_id' => 'required|exists:das_artikel,id', // Pastikan artikel terkait ada
'comment_id' => 'required|exists:das_artikel_comment,id', // Pastikan comment_id ada
]);

try {
// Mendeteksi IP address
$ipAddress = $request->ip();

// Mendeteksi device menggunakan jenssegers/agent
$agent = new Agent();
$device = $agent->device() ?: 'Desktop';
$platform = $agent->platform() ?: 'Unknown Platform';
$browser = $agent->browser() ?: 'Unknown Browser';

// Format informasi device
$deviceInfo = "{$device} on {$platform} using {$browser}";

$comment = \App\Models\Comment::create([
'nama' => $request->nama,
'email' => $request->email,
'body' => $request->body,
'status' => 'disable',
'das_artikel_id' => $request->das_artikel_id,
'comment_id' => $request->comment_id,
'ip_address' => $ipAddress,
'device' => $deviceInfo
]);

// Simpan comment_id ke dalam session agar user bisa melihat komentarnya sendiri
$request->session()->push('session_user_comments', $comment->id);

return redirect()->back()->with('success', 'Balasan berhasil dikirim.');
} catch (\Throwable $th) {
return redirect()->back()->withInput($request->all())->withErrors([$th->getMessage()]);
}
}


public function eventDetail($slug)
{
$event = Event::slug($slug)->firstOrFail();
Expand Down
79 changes: 79 additions & 0 deletions app/Http/Controllers/FrontEnd/PublikasiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

/*
* File ini bagian dari:
*
* OpenDK
*
* Aplikasi dan source code ini dirilis berdasarkan lisensi GPL V3
*
* Hak Cipta 2017 - 2024 Perkumpulan Desa Digital Terbuka (https://opendesa.id)
*
* Dengan ini diberikan izin, secara gratis, kepada siapa pun yang mendapatkan salinan
* dari perangkat lunak ini dan file dokumentasi terkait ("Aplikasi Ini"), untuk diperlakukan
* tanpa batasan, termasuk hak untuk menggunakan, menyalin, mengubah dan/atau mendistribusikan,
* asal tunduk pada syarat berikut:
*
* Pemberitahuan hak cipta di atas dan pemberitahuan izin ini harus disertakan dalam
* setiap salinan atau bagian penting Aplikasi Ini. Barang siapa yang menghapus atau menghilangkan
* pemberitahuan ini melanggar ketentuan lisensi Aplikasi Ini.
*
* PERANGKAT LUNAK INI DISEDIAKAN "SEBAGAIMANA ADANYA", TANPA JAMINAN APA PUN, BAIK TERSURAT MAUPUN
* TERSIRAT. PENULIS ATAU PEMEGANG HAK CIPTA SAMA SEKALI TIDAK BERTANGGUNG JAWAB ATAS KLAIM, KERUSAKAN ATAU
* KEWAJIBAN APAPUN ATAS PENGGUNAAN ATAU LAINNYA TERKAIT APLIKASI INI.
*
* @package OpenDK
* @author Tim Pengembang OpenDesa
* @copyright Hak Cipta 2017 - 2024 Perkumpulan Desa Digital Terbuka (https://opendesa.id)
* @license http://www.gnu.org/licenses/gpl.html GPL V3
* @link https://github.com/OpenSID/opendk
*/

namespace App\Http\Controllers\FrontEnd;

use App\Facades\Counter;
use App\Http\Controllers\FrontEndController;
use App\Models\Album;
use App\Models\Galeri;
use Illuminate\Support\Facades\DB;

class PublikasiController extends FrontEndController
{
public function album()
{
Counter::count('publikasi.galeri');

$albums = Album::status()->with(['galeris'])->paginate(9);


$page_title = 'Galeri';


return view('pages.publikasi.album', compact('page_title', 'albums'));
}

public function galeri($slug)
{
Counter::count('publikasi.galeri');

$galeris = Galeri::status()->whereRelation('album', 'slug', $slug)->paginate(9);
// $album = Album::with(['galeris'])->where('slug', $slug)->first();

$page_title = 'Galeri';


return view('pages.publikasi.galeri', compact('page_title', 'galeris'));
}

public function galeri_detail($slug)
{
Counter::count('publikasi.galeri');

$galeri = Galeri::where('slug', $slug)->first();

$page_title = 'Galeri';


return view('pages.publikasi.galeri_detail', compact('page_title', 'galeri'));
}
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/FrontEnd/SistemKomplainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public function kirim()
public function tracking(Request $request)
{
try {
$komplain = Komplain::where('komplain_id', '=', $request->post('q'))->firstOrFail();

$komplain = Komplain::where('komplain_id', '=', $request->post('tracking_id'))->firstOrFail();
return redirect()->route('sistem-komplain.komplain', $komplain->slug);
} catch (\Exception $e) {
report($e);
Expand Down
Loading

0 comments on commit 3524f16

Please sign in to comment.