ojoks di senggols ojoks di shilats

cuek
This commit is contained in:
ghozahimma65 2025-10-02 10:41:40 +07:00
parent 5168a6c249
commit 0c37f99ee8
11 changed files with 327 additions and 40 deletions

View File

@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Pengumuman;
use Illuminate\Http\Request;
class PengumumanController extends Controller
{
public function index()
{
$pengumuman = Pengumuman::latest()->get();
return view('admin.pengumuman.index', compact('pengumuman'));
}
public function create()
{
return view('admin.pengumuman.create');
}
public function store(Request $request)
{
$request->validate([
'judul' => 'required|string|max:255',
'isi' => 'required|string',
'tanggal_mulai' => 'nullable|date',
'tanggal_selesai' => 'nullable|date|after_or_equal:tanggal_mulai',
'status' => 'boolean',
]);
Pengumuman::create($request->all());
return redirect()->route('pengumuman.index')->with('success', 'Pengumuman berhasil ditambahkan.');
}
public function edit(Pengumuman $pengumuman)
{
return view('admin.pengumuman.edit', compact('pengumuman'));
}
public function update(Request $request, Pengumuman $pengumuman)
{
$request->validate([
'judul' => 'required|string|max:255',
'isi' => 'required|string',
'tanggal_mulai' => 'nullable|date',
'tanggal_selesai' => 'nullable|date|after_or_equal:tanggal_mulai',
'status' => 'boolean',
]);
$pengumuman->update($request->all());
return redirect()->route('pengumuman.index')->with('success', 'Pengumuman berhasil diperbarui.');
}
public function destroy(Pengumuman $pengumuman)
{
$pengumuman->delete();
return redirect()->route('pengumuman.index')->with('success', 'Pengumuman berhasil dihapus.');
}
}

View File

@ -7,19 +7,18 @@
use App\Models\Siswa;
use App\Models\WaliMurid;
use App\Models\Kelas;
use App\Models\Pengumuman;
class DashboardController extends Controller
{
public function index()
{
$pengumuman = "Besok ada kegiatan belajar di kantor polisi";
$jadwal = "Pembelajaran di kantor polisi - 8 a.m.";
$aktivitas = [
['nama' => 'Winda Kurnia', 'waktu' => '01 Aug, 09:20AM'],
['nama' => 'Siti Nurhaliza', 'waktu' => '01 Aug, 04:20PM'],
['nama' => 'Daffa Lintang', 'waktu' => '01 Aug, 08:20AM'],
{
$pengumuman = Pengumuman::orderBy('created_at', 'desc')->first();
$aktivitas = [
(object)['deskripsi' => 'Admin menambahkan data guru', 'created_at' => now()],
(object)['deskripsi' => 'Admin membuat pengumuman baru', 'created_at' => now()->subHour()],
];
return view('dashboard', compact('pengumuman', 'jadwal', 'aktivitas'));
}
return view('dashboard', compact('pengumuman','aktivitas'));
}
}

22
app/Models/Pengumuman.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Pengumuman extends Model
{
use HasFactory;
protected $table = 'pengumuman'; // <- perbaikan disini
protected $fillable = [
'judul',
'isi',
'tanggal_mulai',
'tanggal_selesai',
'status',
];
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pengumuman', function (Blueprint $table) {
$table->id();
$table->string('judul');
$table->text('isi');
$table->date('tanggal_mulai');
$table->date('tanggal_selesai');
$table->boolean('status')->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pengumuman');
}
};

View File

@ -0,0 +1,48 @@
@extends('layouts.app')
@section('content')
<div class="bg-white shadow-md rounded-lg p-6 max-w-2xl mx-auto">
<h1 class="text-xl font-semibold mb-4 text-gray-700"> Tambah Pengumuman</h1>
<form action="{{ route('pengumuman.store') }}" method="POST">
@csrf
<div class="mb-4">
<label class="block text-gray-600 font-medium mb-1">Judul</label>
<input type="text" name="judul" value="{{ old('judul') }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300" required>
</div>
<div class="mb-4">
<label class="block text-gray-600 font-medium mb-1">Isi Pengumuman</label>
<textarea name="isi" rows="4"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300" required>{{ old('isi') }}</textarea>
</div>
<div class="mb-4 grid grid-cols-2 gap-4">
<div>
<label class="block text-gray-600 font-medium mb-1">Tanggal Mulai</label>
<input type="date" name="tanggal_mulai" value="{{ old('tanggal_mulai') }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300">
</div>
<div>
<label class="block text-gray-600 font-medium mb-1">Tanggal Selesai</label>
<input type="date" name="tanggal_selesai" value="{{ old('tanggal_selesai') }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300">
</div>
</div>
<div class="mb-4">
<label class="inline-flex items-center">
<input type="checkbox" name="status" value="1" class="mr-2" checked>
<span class="text-gray-700">Aktif</span>
</label>
</div>
<div class="flex justify-end gap-2">
<a href="{{ route('pengumuman.index') }}" class="bg-gray-300 px-4 py-2 rounded hover:bg-gray-400">Batal</a>
<button type="submit" class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700">Simpan</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,49 @@
@extends('layouts.app')
@section('content')
<div class="bg-white shadow-md rounded-lg p-6 max-w-2xl mx-auto">
<h1 class="text-xl font-semibold mb-4 text-gray-700">✏️ Edit Pengumuman</h1>
<form action="{{ route('pengumuman.update', $pengumuman->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-4">
<label class="block text-gray-600 font-medium mb-1">Judul</label>
<input type="text" name="judul" value="{{ old('judul', $pengumuman->judul) }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300" required>
</div>
<div class="mb-4">
<label class="block text-gray-600 font-medium mb-1">Isi Pengumuman</label>
<textarea name="isi" rows="4"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300" required>{{ old('isi', $pengumuman->isi) }}</textarea>
</div>
<div class="mb-4 grid grid-cols-2 gap-4">
<div>
<label class="block text-gray-600 font-medium mb-1">Tanggal Mulai</label>
<input type="date" name="tanggal_mulai" value="{{ old('tanggal_mulai', $pengumuman->tanggal_mulai) }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300">
</div>
<div>
<label class="block text-gray-600 font-medium mb-1">Tanggal Selesai</label>
<input type="date" name="tanggal_selesai" value="{{ old('tanggal_selesai', $pengumuman->tanggal_selesai) }}"
class="w-full border rounded px-3 py-2 focus:outline-none focus:ring focus:ring-green-300">
</div>
</div>
<div class="mb-4">
<label class="inline-flex items-center">
<input type="checkbox" name="status" value="1" class="mr-2" {{ $pengumuman->status ? 'checked' : '' }}>
<span class="text-gray-700">Aktif</span>
</label>
</div>
<div class="flex justify-end gap-2">
<a href="{{ route('pengumuman.index') }}" class="bg-gray-300 px-4 py-2 rounded hover:bg-gray-400">Batal</a>
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">Update</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,46 @@
@extends('layouts.app')
@section('content')
<div class="bg-white shadow-md rounded p-6">
<div class="flex justify-between items-center mb-4">
<h1 class="text-xl font-semibold">📢 Pengumuman</h1>
<a href="{{ route('pengumuman.create') }}" class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700">+ Tambah</a>
</div>
<table class="w-full border-collapse">
<thead>
<tr class="bg-green-600 text-white">
<th class="p-2">#</th>
<th class="p-2">Judul</th>
<th class="p-2">Tanggal</th>
<th class="p-2">Status</th>
<th class="p-2">Aksi</th>
</tr>
</thead>
<tbody>
@foreach ($pengumuman as $i => $p)
<tr class="border-b hover:bg-gray-50">
<td class="p-2">{{ $i+1 }}</td>
<td class="p-2 font-semibold">{{ $p->judul }}</td>
<td class="p-2">
{{ $p->tanggal_mulai }} - {{ $p->tanggal_selesai }}
</td>
<td class="p-2">
<span class="px-2 py-1 rounded text-white {{ $p->status ? 'bg-green-500' : 'bg-gray-400' }}">
{{ $p->status ? 'Aktif' : 'Nonaktif' }}
</span>
</td>
<td class="p-2 flex gap-2">
<a href="{{ route('pengumuman.edit', $p->id) }}" class="bg-blue-500 text-white px-3 py-1 rounded hover:bg-blue-600">Edit</a>
<form action="{{ route('pengumuman.destroy', $p->id) }}" method="POST" onsubmit="return confirm('Yakin hapus?')">
@csrf
@method('DELETE')
<button class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">Hapus</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

View File

@ -1,40 +1,56 @@
@extends('layouts.app')
@section('content')
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="p-6">
<h1 class="text-2xl font-semibold mb-6">Hai, Admin 👋</h1>
<!-- Pengumuman -->
<div class="bg-white p-6 rounded-xl shadow">
<h2 class="font-bold text-gray-800 mb-3">📢 Pengumuman</h2>
<p>{{ $pengumuman ?? 'Belum ada pengumuman.' }}</p>
</div>
<!-- Jadwal -->
<div class="bg-white p-6 rounded-xl shadow">
<div class="flex justify-between items-center mb-3">
<h2 class="font-bold text-gray-800">📅 Jadwal</h2>
<a href="#" class="text-sm text-red-500 hover:underline">See all</a>
<!-- Baris 1: Pengumuman (full width) -->
<div class="mb-6">
<div class="bg-white shadow rounded-lg p-4">
<h2 class="text-lg font-semibold flex items-center mb-2">📢 Pengumuman Terbaru</h2>
@if($pengumuman)
<h4>{{ $pengumuman->judul }}</h4>
<p>{{ $pengumuman->isi }}</p>
<small>
Periode: {{ $pengumuman->tanggal_mulai }} - {{ $pengumuman->tanggal_selesai }}
@if(now()->between($pengumuman->tanggal_mulai, $pengumuman->tanggal_selesai))
<span class="badge bg-success">Aktif</span>
@else
<span class="badge bg-secondary">Belum aktif</span>
@endif
</small>
@else
<p>Belum ada pengumuman.</p>
@endif
</div>
<p>🔔 {{ $jadwal ?? 'Belum ada jadwal.' }}</p>
</div>
<!-- Aktivitas Peserta Didik -->
<div class="bg-white p-6 rounded-xl shadow">
<div class="flex justify-between items-center mb-3">
<h2 class="font-bold text-gray-800">🧒 Aktivitas Peserta Didik</h2>
<a href="#" class="text-sm text-red-500 hover:underline">See all</a>
<!-- Baris 2: Jadwal & Aktivitas -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Jadwal -->
<div class="bg-white shadow rounded-lg p-4">
<div class="flex justify-between items-center mb-2">
<h2 class="text-lg font-semibold flex items-center">📅 Jadwal</h2>
<a href="#" class="text-red-500 text-sm">See all</a>
</div>
<p class="text-gray-400">Belum ada jadwal.</p>
</div>
<ul class="space-y-3">
@forelse ($aktivitas as $a)
<li class="flex items-center justify-between border-b pb-2">
<span>{{ $a['nama'] }}</span>
<span class="text-sm text-gray-500">{{ $a['waktu'] }}</span>
</li>
@empty
<li>Belum ada aktivitas.</li>
@endforelse
</ul>
</div>
<!-- Aktivitas -->
<div class="bg-white shadow rounded-lg p-4">
<h2 class="text-lg font-semibold flex items-center mb-2">📌 Aktivitas Terbaru</h2>
<ul class="space-y-1 text-gray-600 text-sm">
@forelse($aktivitas as $item)
<li> {{ $item->deskripsi }}
<span class="text-gray-400"> - {{ $item->created_at->diffForHumans() }}</span>
</li>
@empty
<li class="text-gray-400">Tidak ada aktivitas terbaru.</li>
@endforelse
</ul>
</div>
</div>
</div>
@endsection

View File

@ -30,7 +30,7 @@
<i class="fas fa-chart-line mr-3"></i> Laporan Perkembangan
</a>
<a href="#" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
<a href="{{ route('pengumuman.index') }}" class="flex items-center p-2 rounded-lg hover:bg-green-700 transition">
<i class="fas fa-bullhorn mr-3"></i> Menu Pengumuman
</a>

View File

@ -8,6 +8,7 @@
use App\Http\Controllers\Admin\GuruController;
use App\Http\Controllers\Admin\WaliMuridController;
use App\Http\Controllers\Admin\SiswaController;
use App\Http\Controllers\Api\PerkembanganController as ApiPerkembangan;
Route::post('/login', [AuthController::class, 'login']);
@ -41,5 +42,5 @@
'update' => 'api.siswa.update',
'destroy' => 'api.siswa.destroy',
]);
Route::middleware('auth:sanctum')->get('/wali/perkembangan', [ApiPerkembangan::class,'index']);
});

View File

@ -6,6 +6,9 @@
use App\Http\Controllers\Admin\GuruController;
use App\Http\Controllers\Admin\WaliMuridController;
use App\Http\Controllers\Admin\SiswaController;
use App\Http\Controllers\Admin\PengumumanController;
use App\Http\Controllers\Guru\PerkembanganController as GuruPerkembangan;
use App\Http\Controllers\Admin\PerkembanganController as AdminPerkembangan;
// Login routes
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
@ -20,10 +23,20 @@
// Hanya bisa diakses setelah login
Route::middleware('auth')->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
Route::resource('pengumuman', \App\Http\Controllers\Admin\PengumumanController::class);
Route::prefix('admin')->group(function () {
Route::resource('guru', GuruController::class);
Route::resource('wali', WaliMuridController::class);
Route::resource('siswa', SiswaController::class);
Route::middleware(['auth','role:guru'])->prefix('guru')->name('guru.')->group(function(){
Route::resource('perkembangan', GuruPerkembangan::class);
});
Route::middleware(['auth','role:admin'])->prefix('admin')->name('admin.')->group(function(){
Route::get('perkembangan', [AdminPerkembangan::class, 'index'])->name('perkembangan.index');
Route::get('perkembangan/{id}', [AdminPerkembangan::class, 'show'])->name('perkembangan.show');
});
});
});