'datetime', 'TanggalDiproses' => 'datetime', 'TingkatKekhawatiran' => 'integer' ]; /** * Get the activity this feedback belongs to */ public function informasiKegiatan() { return $this->belongsTo(InformasiKegiatan::class, 'KegiatanID'); } /** * Scope for pending feedback */ public function scopePending($query) { return $query->where('Status', 'pending'); } /** * Scope for approved feedback */ public function scopeApproved($query) { return $query->where('Status', 'approved'); } /** * Scope for rejected feedback */ public function scopeRejected($query) { return $query->where('Status', 'rejected'); } /** * Scope by role */ public function scopeByRole($query, $role) { return $query->where('Peran', $role); } /** * Get the rating level description */ public function getRatingDescriptionAttribute() { $descriptions = [ 1 => 'Sangat Khawatir', 2 => 'Khawatir', 3 => 'Netral', 4 => 'Berharap', 5 => 'Sangat Berharap' ]; return $descriptions[$this->TingkatKekhawatiran] ?? 'Tidak Diketahui'; } /** * Get formatted submission date */ public function getFormattedSubmissionDateAttribute() { return $this->TanggalDiajukan->format('d M Y H:i'); } /** * Get photo URL */ public function getPhotoUrlAttribute() { if ($this->FotoSelfie) { return asset('storage/feedback-photos/' . $this->FotoSelfie); } return null; } /** * Approve this feedback */ public function approve($adminNote = null) { $this->update([ 'Status' => 'approved', 'CatatanAdmin' => $adminNote, 'TanggalDiproses' => now() ]); } /** * Reject this feedback */ public function reject($adminNote = null) { $this->update([ 'Status' => 'rejected', 'CatatanAdmin' => $adminNote, 'TanggalDiproses' => now() ]); } }