Octobercms显示在columns.yaml中

How to display the count relationship in column.yaml? Please check my code.

User.php Model

public $hasMany = [
    'views' => ['Acme\Analytics\Models\View'],
    'views_count' => ['Acme\Analytics\Models\View', 'count' => true]
];

columns.yaml

# ===================================
#  List Column Definitions
# ===================================

columns:
    views_count:
        label: Views

Display or return value

[{"user_id":1,"count":3}] 

The return value is correct but i only need the count value to display in the column fields. Any help is greatly appreciated.

Try

# ===================================
#  List Column Definitions
# ===================================

columns:
    views_count:
        label: Views
        select: count

It's very old question but I am facing the same issue.

Here is the solution

# ===================================
#  List Column Definitions
# ===================================

columns:
    views_count:
        label: Views
        relation: views_count
        valueFrom: count

You can read more at https://octobercms.com/docs/backend/lists#column-relation

Correct answer is useRelationCount:

columns:
  views_count:
    label: Views
    relation: views_count
    useRelationCount: true

Other two answers here won't work. select will crash app with "field not found" error, valueFrom will push empty string, comma separated for every record.