From c126073273cf8fdbadc69af6052865674571d7d1 Mon Sep 17 00:00:00 2001 From: rahmagustin Date: Thu, 5 Mar 2026 21:16:19 +0700 Subject: [PATCH] pengumuman user --- app/Http/Controllers/PengumumanController.php | 31 ++++++++- resources/views/user/pengumuman.blade.php | 68 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 resources/views/user/pengumuman.blade.php diff --git a/app/Http/Controllers/PengumumanController.php b/app/Http/Controllers/PengumumanController.php index e98dc69..e1a506d 100644 --- a/app/Http/Controllers/PengumumanController.php +++ b/app/Http/Controllers/PengumumanController.php @@ -2,9 +2,38 @@ namespace App\Http\Controllers; +use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use App\Models\Pengumuman; +use Carbon\Carbon; class PengumumanController extends Controller { - // + + public function index() + { + $pengumuman = Pengumuman::orderBy('tanggal_pengumuman', 'desc')->paginate(6); // Pagination 6 per halaman + + return view('user.pengumuman', compact('pengumuman')); + } + + public function show($id) + { + + $pengumuman = Pengumuman::findOrFail($id); + + $recentPengumuman = Pengumuman::where('id_pengumuman', '!=', $id) + ->orderBy('tanggal_pengumuman', 'desc') + ->limit(5) + ->get(); + + return view('user.detail-pengumuman', compact('pengumuman', 'recentPengumuman')); + } + + public function hero() + { + $pengumumanHero = Pengumuman::orderBy('tanggal_pengumuman', 'desc')->take(3)->get(); + + return view('user.index', compact('pengumumanHero')); + } } diff --git a/resources/views/user/pengumuman.blade.php b/resources/views/user/pengumuman.blade.php new file mode 100644 index 0000000..f518980 --- /dev/null +++ b/resources/views/user/pengumuman.blade.php @@ -0,0 +1,68 @@ +@extends('user.template') + +@section('title', 'Pengumuman') + +@section('content') + +
+
+

Pengumuman

+ +
+
+ + +
+
+
+ + @forelse ($pengumuman as $item) +
+
+ +
+ @if ($item->gambar_pengumuman) + {{ $item->judul_pengumuman }} + @else + default + @endif +
+ + + +

+ + {{ Str::limit($item->judul_pengumuman, 30) }} + +

+ +
+ +
+ +
+
+ @empty +

Belum ada pengumuman tersedia.

+ @endforelse + +
+ +
+
+ +@endsection