feat: menu & API Informasi Sekolah untuk aplikasi wali
- Tabel school_informations (judul, isi, kategori, tanggal kegiatan, publish) - Menu admin 'Informasi Sekolah' (CRUD + permission manage-school-info) - API wali: GET /parent/school-informations (hanya yang dipublikasikan) - 2 data contoh: Jadwal UTS & Class Meet - Test suite tetap hijau (39 test)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SchoolInformation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ParentSchoolInformationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Daftar informasi sekolah yang dipublikasikan (untuk app wali murid).
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$items = SchoolInformation::query()
|
||||
->where('is_published', true)
|
||||
->orderByDesc('event_date')
|
||||
->orderByDesc('created_at')
|
||||
->limit(50)
|
||||
->get()
|
||||
->map(fn (SchoolInformation $i) => [
|
||||
'id' => $i->id,
|
||||
'title' => $i->title,
|
||||
'content' => $i->content,
|
||||
'category' => $i->category,
|
||||
'event_date' => $i->event_date?->toDateString(),
|
||||
'created_at' => $i->created_at?->toISOString(),
|
||||
]);
|
||||
|
||||
return response()->json(['informations' => $items]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user