'datetime', ]; /** * Get user's notifications * Performance: Use with eager loading when needed * Example: User::with('notifications')->find($id) */ public function notifications() { return $this->hasMany(\App\Models\Notification::class); } /** * Get user's unread notifications count * Performance: Direct count query without loading records */ public function unreadNotificationsCount() { return $this->notifications()->where('is_read', false)->count(); } }