diff --git a/app/Http/Controllers/Pengaturan/PengumumanController.php b/app/Http/Controllers/Pengaturan/PengumumanController.php
index 8cf38c6..30c4c24 100644
--- a/app/Http/Controllers/Pengaturan/PengumumanController.php
+++ b/app/Http/Controllers/Pengaturan/PengumumanController.php
@@ -4,15 +4,77 @@ namespace App\Http\Controllers\Pengaturan;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\File;
+use Carbon\Carbon;
+use App\Models\FilePengumuman;
class PengumumanController extends Controller
{
+ protected $title = 'Pengumuman/Peraturan';
+ protected $template = 'modules.pengaturan.pengumuman';
+ protected $route = 'modules.pengaturan.pengumuman';
+
/**
* Display a listing of the resource.
*/
public function index()
{
- //
+ permission('is_read', $this->route, 'module',true);
+
+ $data['breadcrumbs'] = [
+ ['name' => 'Dashboard'],
+ ['name' => 'Pengaturan'],
+ ['name' => 'Pengumuman/Peraturan','active' => true],
+ ];
+ $data['title'] = $this->title;
+ $data['route'] = $this->route;
+
+ return view($this->template.'.index',$data);
+ }
+
+ public function grid(Request $request)
+ {
+
+ $data = FilePengumuman::all();
+ $_data = [];
+
+
+ foreach ($data as $key => $row) {
+
+
+ $action = '';
+ $status = '';
+ if($row->status == 0){
+ $status = ' Tidak Aktif ';
+ }else{
+ $status = ' Aktif ';
+ }
+ $file = '';
+ $action .= '
';
+ if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
+ $action .= '
';
+ if(session('group_id') == 1){
+ $action .= '
';
+ }
+ }
+ $action .= '
';
+
+ $_data[] = [
+ 'no' => $key+1,
+ 'id' => encode_id($row->FilePengumumanId),
+ 'tahun' => @$row->tahun,
+ 'nama' => @$row->nama,
+ 'file' => @$file,
+ 'created_at' => date('d-m-Y H:i:s',strtotime(@$row->created_at)),
+ 'status' => @$status,
+ 'action' => @$action,
+ ];
+
+ }
+
+ // return response()->json($_data); // Return the data as a JSON response
+ return response()->json($_data);
+
}
/**
@@ -28,7 +90,69 @@ class PengumumanController extends Controller
*/
public function store(Request $request)
{
- //
+ // dd(request()->all());
+ $request->validate([
+ 'tahun' => 'required',
+ 'nama' => 'required',
+ 'file' => 'required|file|mimes:xls,xlsx,pdf,png,jpg,jpeg,docx|max:2000',
+ ]);
+
+ try {
+
+ if (@$request->file) {
+ $file = $request->file;
+ $destinationPath = public_path('uploads/pengumuman');
+ $current = Carbon::now()->format('Y/m/d');
+ $path = $destinationPath . '/' . $current;
+ $fileName = $file->getClientOriginalName();
+ $fileMime = $file->getClientMimeType();
+ $fileExtension = $file->getClientOriginalExtension();
+ $fileSize = $file->getSize();
+ if(($fileExtension != 'xls') && ($fileExtension != 'xlsx') && ($fileExtension != 'pdf') && ($fileExtension != 'docx') && ($fileExtension != 'png') && ($fileExtension != 'jpg') && ($fileExtension != 'jpeg') ){
+ return redirect()->back()->with([
+ 'message' => 'Maaf File Harus Berupa xls,xlsx,pdf,png,jpg,jpeg,docx!',
+ 'type' => "error"
+ ]);
+ }
+ $newFilename = session('id').'_'.uniqid('file_') . '.' . $fileExtension;
+
+ if (!File::exists($path)) {
+ File::isDirectory($path) or File::makeDirectory($path, 0777, true, true);
+ }
+
+ $filePath = 'pengumuman/' . $current . '/' . $newFilename;
+ $uploaded = $file->move($path, $newFilename);
+ }
+
+
+ if(@request()->secure_id){
+ $keyId = decode_id(@request()->secure_id);
+ $data = FilePengumuman::find($keyId);
+ $data->tahun = $request->tahun;
+ $data->nama = $request->nama;
+ $data->file = $filePath;
+ $data->deskripsi = $request->deskripsi;
+ $data->save();
+ }else{
+ $data = new FilePengumuman;
+ $data->tahun = $request->tahun;
+ $data->nama = $request->nama;
+ $data->file = $filePath;
+ $data->deskripsi = $request->deskripsi;
+ $data->save();
+ }
+
+
+ return redirect()->back()->with([
+ 'message' => 'Berhasil update data',
+ 'type' => 'success',
+ ]);
+ } catch (\Exception $e) {
+ return redirect()->back()->with([
+ 'message' => 'Gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage(),
+ 'type' => 'error',
+ ]);
+ }
}
/**
@@ -50,9 +174,29 @@ class PengumumanController extends Controller
/**
* Update the specified resource in storage.
*/
- public function update(Request $request, string $id)
+ public function update($id = null)
{
- //
+ $data['breadcrumbs'] = [
+ ['name' => 'Dashboard'],
+ ['name' => 'Pengaturan'],
+ ['name' => 'Data Aktivitas','active' => true],
+ ];
+ $keyId = decode_id($id);
+ $data['title'] = $this->title;
+ $data['route'] = $this->route;
+ $data['keyId'] = $id;
+ $data['item'] = FilePengumuman::where('FilePengumumanId',$keyId)->first();
+
+ return view($this->template.'.form',$data);
+ }
+
+ public function delete($id)
+ {
+ $keyId = decode_id($id);
+
+ $data = FilePengumuman::where('FilePengumumanId',$keyId)->delete();
+
+ return response()->json(['success' => true,'message' => 'Berhasil update data','type' => 'success']);
}
/**
diff --git a/app/Models/FilePengumuman.php b/app/Models/FilePengumuman.php
index 8dfb8a6..f4f2e72 100644
--- a/app/Models/FilePengumuman.php
+++ b/app/Models/FilePengumuman.php
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class FilePengumuman extends Model
{
- use SoftDeletes;
+ // use SoftDeletes;
protected $table = 'file_pengumuman';
protected $primaryKey = 'FilePengumumanId';
diff --git a/public/uploads/pengumuman/2025/12/18/_file_69437314dcabb.xlsx b/public/uploads/pengumuman/2025/12/18/_file_69437314dcabb.xlsx
new file mode 100644
index 0000000..45d22a7
Binary files /dev/null and b/public/uploads/pengumuman/2025/12/18/_file_69437314dcabb.xlsx differ
diff --git a/resources/views/modules/pengaturan/pengumuman/form.blade.php b/resources/views/modules/pengaturan/pengumuman/form.blade.php
index 51a8661..7fcba45 100644
--- a/resources/views/modules/pengaturan/pengumuman/form.blade.php
+++ b/resources/views/modules/pengaturan/pengumuman/form.blade.php
@@ -8,20 +8,25 @@
-