im trying to show the song name, and how many times the song is listened. like this, it works. the problem comes when i want to filter by certain user:
Tables\Filters\SelectFilter::make('user') ->relationship('plays', 'name') ->query(function (Builder $query, array $data): Builder { return $query->when(($data['value'] ?? null) > 0, function (Builder $query) use ($data) { $query->withCount(['plays' => function ($q) use ($data) { $q->where('is_listened', true); $q->where('user_song_play_history.user_id', $data['value']); }]); }); })
Tables\Filters\SelectFilter::make('user') ->relationship('plays', 'name') ->query(function (Builder $query, array $data): Builder { return $query->when(($data['value'] ?? null) > 0, function (Builder $query) use ($data) { $query->withCount(['plays' => function ($q) use ($data) { $q->where('is_listened', true); $q->where('user_song_play_history.user_id', $data['value']); }]); }); })
it just doesnt work. the field to be filtered is the
user_song_play_history.user_id
user_song_play_history.user_id
. is this the right way to do it?
if i manually filter it (uncommenting the commented line in the query fn) works, but if i filter via the gui, it doesnt