'decimal:8', 'longitude' => 'decimal:8', 'radius' => 'decimal:2', 'attributes' => 'array', 'is_active' => 'boolean', ]; /** * Get the user that owns the geofence */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get devices assigned to this geofence */ public function devices(): BelongsToMany { return $this->belongsToMany(Device::class, 'device_geofences'); } /** * Get events related to this geofence */ public function events(): HasMany { return $this->hasMany(Event::class); } /** * Scope for active geofences */ public function scopeActive($query) { return $query->where('is_active', true); } /** * Get geofence type color */ public function getTypeColor(): string { return match ($this->type) { 'circle' => 'blue', 'polygon' => 'green', default => 'gray' }; } }