'array', 'last_seen_at' => 'datetime', ]; public function room(): BelongsTo { return $this->belongsTo(Room::class); } public function entities(): HasMany { return $this->hasMany(Entity::class); } /** * Reachable now. Real devices use last_seen recency (kept fresh by MQTT from Phase 3); * a mock device with no last_seen is treated as reachable so the demo doesn't rot. */ public function isOnline(): bool { if ($this->status !== 'active') { return false; } return $this->last_seen_at === null || $this->last_seen_at->gt(now()->subMinutes(10)); } }