Skip to content

Is there any possibility to display count of hasMany relation? #1307

Closed Answered by nikosid
nikosid asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like this works:

Column::make('Clicks')
  ->label(function ($row) {
    return $row->statistics_count;
  })
  ->sortable(function($query, $sortOrder) {
    return $query->orderBy('statistics_count', $sortOrder);
  }),

Replies: 2 comments 2 replies

Comment options

lrljoe
Aug 20, 2023
Collaborator Sponsor

You must be logged in to vote
1 reply
@nikosid
Comment options

Comment options

You must be logged in to vote
1 reply
@lrljoe
Comment options

lrljoe Aug 21, 2023
Collaborator Sponsor

Answer selected by nikosid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants