'datetime', 'password' => 'hashed', 'trusted_devices' => 'array', ]; /* |-------------------------------------------------------------------------- | 🔥 HELPER ROLE |-------------------------------------------------------------------------- */ public function isAdmin() { return $this->role === 'admin'; } public function isGuru() { return $this->role === 'guru'; } public function isSiswa() { return $this->role === 'siswa'; } /* |-------------------------------------------------------------------------- | 🔥 RELASI |-------------------------------------------------------------------------- */ // ✅ USER -> GURU public function guru() { return $this->belongsTo(Guru::class, 'guru_id'); } // ✅ USER -> SISWA public function siswa() { return $this->belongsTo(Siswa::class, 'siswa_id'); } // ✅ USER -> MAPEL public function mapel() { return $this->belongsTo(MataPelajaran::class, 'mapel_id'); } /* |-------------------------------------------------------------------------- | 🔥 HELPER TAMBAHAN (OPSIONAL TAPI BAGUS) |-------------------------------------------------------------------------- */ // Ambil nomor WA dengan fallback public function getTeleponLengkap() { if ($this->telepon) { return $this->telepon; } if ($this->guru && $this->guru->telepon) { return $this->guru->telepon; } // 🔥 fallback tambahan (opsional tapi aman) if ($this->siswa && $this->siswa->telepon) { return $this->siswa->telepon; } return null; } }