# `PhoenixLiveCalendar.Resource`
[🔗](https://github.com/mdon/phoenix_live_calendar/blob/v0.5.0/lib/phoenix_live_calendar/resource.ex#L1)

Represents a schedulable resource such as a room, person, or piece of equipment.

Resources are displayed as columns (in day/week resource views) or rows
(in timeline views). Events link to resources via `resource_id` or `resource_ids`.

## Examples

    # Simple room
    %PhoenixLiveCalendar.Resource{id: "room-a", title: "Conference Room A"}

    # Person with type
    %PhoenixLiveCalendar.Resource{
      id: "dr-smith",
      title: "Dr. Smith",
      type: :person,
      color: "bg-accent"
    }

    # Hierarchical: building > room
    %PhoenixLiveCalendar.Resource{id: "floor-1", title: "First Floor"}
    %PhoenixLiveCalendar.Resource{id: "room-101", title: "Room 101", parent_id: "floor-1"}

# `t`

```elixir
@type t() :: %PhoenixLiveCalendar.Resource{
  color: String.t() | nil,
  extra: map(),
  id: term(),
  order: integer() | nil,
  parent_id: term() | nil,
  title: String.t(),
  type: atom() | nil
}
```

# `children`

```elixir
@spec children(t(), [t()]) :: [t()]
```

Returns the children of this resource from a flat list of resources.

# `root?`

```elixir
@spec root?(t()) :: boolean()
```

Returns whether this resource is a root (has no parent).

# `roots`

```elixir
@spec roots([t()]) :: [t()]
```

Returns only root-level resources from a list, sorted by order.

# `to_tree`

```elixir
@spec to_tree([t()]) :: [{t(), list()}]
```

Builds a tree structure from a flat list of resources.

Returns a list of `{resource, children}` tuples where children
is recursively structured the same way.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
