*/ public function toArray(Request $request): array { return [ 'id' => $this->id, // See DeviceResource for why nested resources are ->resolve()'d // rather than returned as bare Resource instances. 'zone' => $this->whenLoaded('zone', fn ($zone) => (new ZoneResource($zone))->resolve()), 'target_device' => $this->whenLoaded('targetDevice', fn ($device) => (new DeviceResource($device))->resolve()), 'condition_source_device' => $this->whenLoaded('conditionSourceDevice', fn ($device) => (new DeviceResource($device))->resolve()), 'condition_sensor_type' => $this->condition_sensor_type, 'condition_operator' => $this->condition_operator->value, 'condition_value' => $this->condition_value, 'action_type' => $this->action_type, 'action_params' => $this->action_params, 'is_active' => $this->is_active, 'created_at' => $this->created_at, ]; } }